Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
TStack_array
/** \file TStack.c * \brief Implementace API pro typ zásobník pomocí pole * \author Kolektivní vědomí ALD * \version 2021 * $Id: TStack.c 1049 2021-02-14 18:22:35Z petyovsky $ */ #include "TStack.h" void stack_init(struct TStack *aStack) { if(aStack) aStack->iCount = 0; } bool stack_is_empty(const struct TStack *aStack) { //může být? /*if (aStack && aStack->iCount) return false;*/ if(aStack) // if(aStack->iCount == 0) // return true; // else // return false; return (aStack->iCount == 0); return true; } bool /* TStackIterator */ stack_top(const struct TStack *aStack, TStackElement *aValue) { if(stack_is_empty(aStack) || !aValue) return false; *aValue = aStack->iValues[aStack->iCount - 1]; return true; } bool stack_push(struct TStack *aStack, TStackElement aValue) { if(aStack && aStack->iCount < STACK_MAXCOUNT) { aStack->iValues[aStack->iCount++] = aValue; return true; } return false; } bool stack_pop(struct TStack *aStack) { if(stack_is_empty(aStack)) return false; --aStack->iCount; return true; } void stack_destroy(struct TStack *aStack) { stack_init(aStack); } struct TStackIterator stack_iterator_begin(const struct TStack *aStack) { if(!stack_is_empty(aStack)) return (struct TStackIterator){ .iStack = aStack, .iPos = aStack->iCount - 1 }; return (struct TStackIterator) { .iStack = NULL, .iPos = 0 }; } bool stack_iterator_is_valid(const struct TStackIterator *aIter) { if(aIter) if(aIter->iStack && aIter->iPos < aIter->iStack->iCount) return true; return false; } bool stack_iterator_to_next(struct TStackIterator *aIter) { if(stack_iterator_is_valid(aIter)) if(aIter->iPos > 0) { --aIter->iPos; return true; } *aIter = (struct TStackIterator) { .iStack = NULL, .iPos = 0 }; return false; } TStackElement stack_iterator_value(const struct TStackIterator *aIter) { if(stack_iterator_is_valid(aIter)) return aIter->iStack->iValues[aIter->iPos]; return (TStackElement) { 0 }; }
run
|
edit
|
history
|
help
0
euklejduv algoritmus
test
BPC UDP cv10 cisla
BPC cv 5_Test
hrátky s ukazately
scanf.c
Fractions n/d that obey (n+5)/(d+2)=3n/d
BPC UDP pr3 cv10
1
tiskunti retezcu a zmena pismenke z malych an velke