Esempio n. 1
0
void push(void* item, Stack* stack){
  if (stack->counter == stack->max)
    stack->container = resizeContainer(stack);
 
  stack->container[stack->counter] = item;
  stack->counter++;
}
Esempio n. 2
0
int enqueue(q_t * q, void *item){
  if(q->size == q->capacity) {

    resizeContainer(q);
  }
  q->rear = (q->rear+1) % q->capacity;
  q->container[q->rear] = item;
  q->size++;
  printf("enqueued now size is %d rear %d\n", q->size,q->rear);
  return 0;
}
Esempio n. 3
0
        void readContainerImpl( std::istream& stream, Container& container, const bool adjustSize )
        {
            typedef typename Container :: value_type T;
            size_t dataSize = 0;
            readValue( stream, dataSize );
            if( adjustSize && dataSize > 0 ) {
                resizeContainer( container, dataSize/sizeof(T) );
            }

            if( dataSize != container.size() * sizeof( T ) )
            {
                OPM_THROW(std::logic_error,
                        "Size of stored data and simulation data does not match"
                        << dataSize << " " << (container.size() * sizeof( T )) );
            }
            if( dataSize > 0 ) {
                readData(stream, container, dataSize);
            }
        }