10 #ifndef _XSENS_LIST_H_2006_06_08
11 #define _XSENS_LIST_H_2006_06_08
15 #ifndef _JANITORS_H_2006_05_01
20 # ifndef _XSENS_LIST_WITH_MATH
21 # define _XSENS_LIST_WITH_MATH
23 # ifndef _XSENS_LIST_IO
24 # define _XSENS_LIST_IO
29 # define _XSENS_LIST_RANGE_CHECKS
32 #ifdef _XSENS_LIST_WITH_MATH
34 # ifndef _XSENS_MATH_H_2006_05_31
35 # include "xsens_math.h"
39 #define XSENS_LIST_NOTFOUND 0xFFFFFFFF
41 #ifdef _XSENS_LIST_RANGE_CHECKS
43 # define XSENS_LIST_THROW
45 # define XSENS_LIST_THROW
103 void append(
const T& item);
111 template <
typename TB>
114 template <
typename TR>
133 template <
typename TB>
140 template <
typename TB>
149 template <
typename T2>
152 template <
typename TB>
155 template <
typename TB>
158 template <
typename TB>
161 template <
typename TB>
184 template <
typename TB>
191 #ifdef _XSENS_LIST_IO
192 #ifdef _XSENS_LIST_WITH_MATH
194 void saveAsMatlab(
const char* filename,
const char *varname)
const;
int32_t serialize(char *buffer) const
IntList(const IntList &src)
Construct a list as a direct copy of another list.
IntList()
Standard constructor, creates an empty list with some room for items.
bool operator==(const IntList &lst)
void setIncremental(const uint32_t start, const uint32_t end, const int32_t step)
int32_t deserialize(const char *str)
IntList(const uint32_t size, uint32_t *src)
Construct a list as a reference to a raw list.
void operator=(const IntList &list)
intentionally NOT implemented due to ambiguous nature
void addValue(int32_t value)
int32_t writeToString(char *buffer) const
IntList(const uint32_t size)
Construct a list with a capacity of at least the given size.
int32_t readFromString(const char *str)
int32_t writeToStringHex(char *buffer) const
Class function calling janitor class.
void append(const T &item)
Adds an item to the end of the list.
void freeItemsOnDestroy(void)
int32_t(* cmpFunc)(const T &, const T &)
A comparison function type, should return -1, 0 or 1 for <, == and >
void appendShallowCopy(const List< T > &source)
Adds the contents of the source list to the end of the list.
uint32_t m_count
The number of items currently in the list.
uint32_t insertSortedDeref(const T &item)
Assumes the list is sorted by dereferenced values and inserts the item at the appropriate spot.
uint32_t removeDuplicateEntries(void)
Removes any duplicate entries and returns the number of items removed. Items are compared directly.
T * m_data
The array containing the items.
T & operator[](const uint32_t index) const XSENS_LIST_THROW
Retrieves the item at the given index. An index beyond the end probably causes an exception.
T & get(const uint32_t index) const XSENS_LIST_THROW
Retrieves the item at the given index. An index beyond the end returns the first item.
uint32_t findDeref(const TB &item) const
Finds an item in an unsorted list (walk over all items) using the T::== operator on dereferenced list...
int32_t(__cdecl * InequalityFunction)(const T &, const T &)
Type for an equality compare function, should return true when NOT equal.
uint32_t findSorted(const TB &item) const
Finds an item in a sorted list (binary search) using the T::== and T::< operators.
void appendDeepCopy(const List< T > &source)
Adds the contents of the source list to the end of the list.
T & last(void) const XSENS_LIST_THROW
Retrieves the last item.
void sortAscendingDeref(void)
Sorts the list in an ascending order, using the T::< operator on dereferenced list items.
List()
Standard constructor, creates an empty list with some room for items.
void deleteAndRemove(const uint32_t index) XSENS_LIST_THROW
Removes an item at the given index in the list.
void reverse(void)
Reverse the order of the list, useful for sorted lists that are read/created in the reverse order.
void deleteAndRemoveTail(const uint32_t count) XSENS_LIST_THROW
void freeAndRemove(const uint32_t index) XSENS_LIST_THROW
Removes an item at the given index in the list.
~List()
Destroy the list. This does NOT automatically delete items IN the list.
uint32_t find(const TB &item) const
Finds an item in an unsorted list (walk over all items) using the T::== operator.
void qSortDeref(uint32_t left, uint32_t right)
Sorts the list in an ascending order, using the T::< operator on dereferenced list items.
uint32_t findSortedDeref(const TB &item) const
Finds an item in a sorted list (binary search) using the T::== and T::< operators on dereferenced lis...
uint32_t m_max
The current size of the data array.
void insertCopy(const TB &item, const uint32_t index)
Inserts a copy of the referenced item at the given index, shifting any items below it down one spot.
void isShallowCopyOf(const List< T > &source)
Overwrites the current list with a shallow (memcopy) copy of another list.
void swap(const uint32_t i, const uint32_t j) XSENS_LIST_THROW
Swaps two items in the list.
JanitorClassFunc< List< T > > * m_jcf
Used to clean up the list on exit.
void clear(void)
Clears the list without explicitly deleting anything.
void appendList(uint32_t count, const T *lst)
Adds a number of items to the end of the list.
void appendCopy(const TB &item)
Adds a copy of a referenced item to the end of the list.
void removeTail(const uint32_t count) XSENS_LIST_THROW
Removes items from the end of the list.
void deleteItemsOnDestroy(void)
uint32_t insertSortedCopy(const TB &item)
Assumes the list is sorted and inserts a copy of the referenced item at the appropriate spot.
void freeAndClear(void)
Calls free for all items in the list and then clears the list.
void operator=(const List &list)
intentionally NOT implemented due to ambiguous nature
uint32_t removeDuplicateEntriesDeref(void)
Removes any duplicate entries and returns the number of items removed. Items are compared after deref...
void insert(const T &item, const uint32_t index)
Inserts an item at the given index, shifting any items below it down one spot.
uint32_t length(void) const
Returns the number of items currently in the list.
void resize(uint32_t newSize)
Resizes the list to at least the given size.
void remove(const uint32_t index) XSENS_LIST_THROW
Removes an item at the given index in the list.
uint32_t insertSorted(const T &item)
Assumes the list is sorted and inserts the item at the appropriate spot.
void deleteAndClear(void)
Calls delete for all items in the list and then clears the list.
void freeAndRemoveTail(const uint32_t count) XSENS_LIST_THROW
void twinSortAscending(List< T2 > &twin)
Sorts the first list in an ascending order, using the T::< operator, the second list will be updated ...
void appendRelated(const TR &item)
Adds a related item to the end of the list, using the T = TR operator.
void qSort(uint32_t left, uint32_t right)
Sorts the list in an ascending order, using the T::< operator.
void sortAscending(void)
Sorts the list in an ascending order, using the T::< operator.
void isDeepCopyOf(const List< T > &source)
Make a copy of the list, duplicating list items i with: copy[i] = new TB(*source[i])
const T * getBuffer(void) const
Returns the start of the linear data buffer.
GLuint GLuint GLsizei count
GLsizei const GLfloat * value
GLsizei GLsizei GLchar * source
The namespace of all Xsens software since 2006.
unsigned __int32 uint32_t