auto-sync
This commit is contained in:
parent
c2d2a6ef0c
commit
53f3dd7238
|
@ -20,10 +20,10 @@ public:
|
|||
void reset();
|
||||
T pop();
|
||||
T get(int index);
|
||||
int size();
|
||||
bool isEmpty();
|
||||
bool_t remove(T value);
|
||||
int size();bool isEmpty();
|
||||
private:
|
||||
int index;
|
||||
int currentSize;
|
||||
T values[MAXSIZE];
|
||||
};
|
||||
|
||||
|
@ -34,32 +34,47 @@ FLStack<T, MAXSIZE>::FLStack() {
|
|||
|
||||
template<typename T, int MAXSIZE>
|
||||
bool FLStack<T, MAXSIZE>::isEmpty() {
|
||||
return index == 0;
|
||||
return currentSize == 0;
|
||||
}
|
||||
|
||||
template<typename T, int MAXSIZE>
|
||||
void FLStack<T, MAXSIZE>::reset() {
|
||||
index = 0;
|
||||
currentSize = 0;
|
||||
}
|
||||
|
||||
template<typename T, int MAXSIZE>
|
||||
bool_t FLStack<T, MAXSIZE>::remove(T value) {
|
||||
for (int i = 0; i < currentSize; i++) {
|
||||
if (values[i] == value) {
|
||||
values[0] = values[currentSize - 1];
|
||||
currentSize--;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
template<typename T, int MAXSIZE>
|
||||
void FLStack<T, MAXSIZE>::push(T value) {
|
||||
if(index >= MAXSIZE) {
|
||||
if (currentSize >= MAXSIZE) {
|
||||
firmwareError("FLstack overflow");
|
||||
return;
|
||||
//warning()
|
||||
}
|
||||
values[index++] = value;
|
||||
values[currentSize++] = value;
|
||||
}
|
||||
|
||||
template<typename T, int MAXSIZE>
|
||||
T FLStack<T, MAXSIZE>::pop() {
|
||||
if (index == 0) {
|
||||
if (currentSize == 0) {
|
||||
firmwareError("FLStack is empty");
|
||||
}
|
||||
return values[--index];
|
||||
return values[--currentSize];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return element at the specified index
|
||||
*/
|
||||
template<typename T, int MAXSIZE>
|
||||
T FLStack<T, MAXSIZE>::get(int index) {
|
||||
efiAssert(index >= 0 && index < MAXSIZE, "FLget", values[0]);
|
||||
|
@ -68,10 +83,10 @@ T FLStack<T, MAXSIZE>::get(int index) {
|
|||
|
||||
template<typename T, int MAXSIZE>
|
||||
int FLStack<T, MAXSIZE>::size() {
|
||||
return index;
|
||||
return currentSize;
|
||||
}
|
||||
|
||||
template <class Type, int Dimention>
|
||||
template<class Type, int Dimention>
|
||||
class ArrayList {
|
||||
public:
|
||||
ArrayList();
|
||||
|
@ -81,19 +96,19 @@ public:
|
|||
Type *add(void);
|
||||
};
|
||||
|
||||
template <class Type, int Dimention>
|
||||
ArrayList< Type, Dimention>::ArrayList(void) {
|
||||
template<class Type, int Dimention>
|
||||
ArrayList<Type, Dimention>::ArrayList(void) {
|
||||
memset(&elements, 0, sizeof(elements));
|
||||
reset();
|
||||
}
|
||||
|
||||
template <class Type, int Dimention>
|
||||
void ArrayList< Type, Dimention>::reset(void) {
|
||||
template<class Type, int Dimention>
|
||||
void ArrayList<Type, Dimention>::reset(void) {
|
||||
size = 0;
|
||||
}
|
||||
|
||||
template <class Type, int Dimention>
|
||||
Type * ArrayList< Type, Dimention>::add(void) {
|
||||
template<class Type, int Dimention>
|
||||
Type * ArrayList<Type, Dimention>::add(void) {
|
||||
efiAssert(size < Dimention, "add() too many elements", (Type *)NULL);
|
||||
return &elements[size++];
|
||||
}
|
||||
|
|
|
@ -150,7 +150,7 @@ int main(void) {
|
|||
testTriggerDecoder();
|
||||
|
||||
// resizeMap();
|
||||
printf("Success 20150213\r\n");
|
||||
printf("Success 20150407\r\n");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
@ -9,10 +9,5 @@
|
|||
#include "test_event_registry.h"
|
||||
#include "main.h"
|
||||
|
||||
static ActuatorEventList eventList;
|
||||
static ActuatorEventList result;
|
||||
|
||||
extern int outputSignalCount;
|
||||
|
||||
void testEventRegistry(void) {
|
||||
}
|
||||
|
|
|
@ -362,6 +362,15 @@ void testFLStack(void) {
|
|||
assertEquals(123, v);
|
||||
assertEquals(0, stack.size());
|
||||
|
||||
stack.push(123);
|
||||
stack.push(234);
|
||||
stack.push(345);
|
||||
stack.push(456);
|
||||
assertEquals(4, stack.size());
|
||||
|
||||
stack.remove(123);
|
||||
assertEquals(456, stack.get(0));
|
||||
assertEquals(3, stack.size());
|
||||
}
|
||||
|
||||
static char buff[32];
|
||||
|
|
Loading…
Reference in New Issue