예제 #1
0
// ---------------------------------------------------------------------------
//  NamespaceScope: Stack access
// ---------------------------------------------------------------------------
unsigned int NamespaceScope::increaseDepth()
{
    // See if we need to expand the stack
    if (fStackTop == fStackCapacity)
        expandStack();

    // If this element has not been initialized yet, then initialize it
    if (!fStack[fStackTop])
    {
        fStack[fStackTop] = new (fMemoryManager) StackElem;
        fStack[fStackTop]->fMapCapacity = 0;
        fStack[fStackTop]->fMap = 0;
    }

    // Set up the new top row
    fStack[fStackTop]->fMapCount = 0;

    // Bump the top of stack
    fStackTop++;

    return fStackTop-1;
}
예제 #2
0
파일: stack.c 프로젝트: Toucanfan/indlprog
void push(stack_t* stack_p, int value) {
	if (stack_p->size == stack_p->capacity)
		expandStack(stack_p);
	stack_p->array[stack_p->size++] = value;
}
예제 #3
0
void push(int element) {
	if (size + 1 > capacity)
		expandStack();
	stackPtr[size++] = element;
	minElement = element < minElement ? element : minElement;
}