-
-
Notifications
You must be signed in to change notification settings - Fork 942
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Each opened app (screen) is pushed on a stack, which is then popped from when returning instead of hard coded "previous apps". Return swipe and refresh directions are automatically determined from the app transition.
- Loading branch information
Showing
4 changed files
with
104 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#include <array> | ||
#include <cstddef> | ||
|
||
template <typename T, size_t N> class StaticStack { | ||
public: | ||
T Pop(); | ||
void Push(T element); | ||
void Reset(); | ||
T Top(); | ||
|
||
private: | ||
std::array<T, N> elementArray; | ||
// Number of elements in stack, points to the next empty slot | ||
size_t stackPointer = 0; | ||
}; | ||
|
||
// Returns random data when popping from empty array. | ||
template <typename T, size_t N> T StaticStack<T, N>::Pop() { | ||
if (stackPointer > 0) { | ||
stackPointer--; | ||
} | ||
return elementArray[stackPointer]; | ||
} | ||
|
||
template <typename T, size_t N> void StaticStack<T, N>::Push(T element) { | ||
if (stackPointer < elementArray.size()) { | ||
elementArray[stackPointer] = element; | ||
stackPointer++; | ||
} | ||
} | ||
|
||
template <typename T, size_t N> void StaticStack<T, N>::Reset() { | ||
stackPointer = 0; | ||
} | ||
|
||
template <typename T, size_t N> T StaticStack<T, N>::Top() { | ||
return elementArray[stackPointer - 1]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters