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