1 #ifndef __THREAD_DYNARRAY_H__
2 #define __THREAD_DYNARRAY_H__
8 #include <TTestCaseContext.h>
11 typedef struct s_ThreadEntry {
14 TestCaseContext_t context;
15 } s_ThreadEntry_t, *ThreadEntry_t;
17 * s_ThreadDynarray struct declaration.
20 typedef struct s_ThreadDynarray {
22 ThreadEntry_t threads;
25 /* Storage capacity */
26 unsigned long capacity;
30 } s_ThreadDynarray_t, *ThreadDynarray_t;
33 * Constructs a ThreadDynarray with the specified capacity.
35 ThreadDynarray_t ThreadDynarray_new(unsigned long capacity);
38 * Destroy the ThreadDynarray
40 void ThreadDynarray_destroy(ThreadDynarray_t ptr);
43 * Returns an const pointer THREAD_entry pointed to by index.
45 ThreadEntry_t const ThreadDynarray_at(ThreadDynarray_t ptr,
49 * Fill the content of the entry addressed by the __entry with the content
50 * of the entry pointed to by index.
52 void ThreadDynarray_get(ThreadDynarray_t ptr, unsigned long index,
53 ThreadEntry_t const __entry);
56 * Fill the content of the entry pointed to by index with the content of
57 * the entry addressed by __entry.
59 void ThreadDynarray_set(ThreadDynarray_t ptr, unsigned long index,
60 ThreadEntry_t const __entry);
63 * Returns a const pointer to the first entry.
65 ThreadEntry_t const ThreadDynarray_getFront(ThreadDynarray_t ptr);
68 * Returns a const pointer to the last entry.
70 ThreadEntry_t const ThreadDynarray_getBack(ThreadDynarray_t ptr);
73 * Inserts a copy of __entry at the front
75 void ThreadDynarray_pushFront(ThreadDynarray_t ptr,
76 ThreadEntry_t const __entry);
79 * Appends a copy of __entry to the end.
81 void ThreadDynarray_pushBack(ThreadDynarray_t ptr,
82 ThreadEntry_t const __entry);
85 * Inserts __entry at the position pointed to by index.
87 void ThreadDynarray_insert(ThreadDynarray_t ptr, unsigned long index,
88 ThreadEntry_t const __entry);
91 * Deletes the entry pointed to by index. If __entry is not NULL the
92 * fuction saves the entry threads at this address before.
94 void ThreadDynarray_erase(ThreadDynarray_t ptr, unsigned long index,
95 ThreadEntry_t const __entry);
98 * Find the first entry with the same content of the entry addressed by
99 * __entry.The function returns the index of the founded entry, -1 if
100 * no entry is founded.
102 long ThreadDynarray_getIndex(ThreadDynarray_t ptr,
103 ThreadEntry_t const __entry);
106 * Returns true if the entry exist.
108 bool ThreadDynarray_exist(ThreadDynarray_t ptr,
109 ThreadEntry_t const __entry);
111 /* Deletes the first entry with the same content of the entry addressed
112 * by __entry.The function returns true if the entry is deleted, false
113 * if no entry is founded.
115 bool ThreadDynarray_remove(ThreadDynarray_t ptr,
116 ThreadEntry_t const __entry);
119 * Erase all elements of the self.
121 void ThreadDynarray_clear(ThreadDynarray_t ptr);
124 * Resets entry count to zero.
126 void ThreadDynarray_reset(ThreadDynarray_t ptr);
129 * Moves count elements from src index to dst index.
131 void ThreadDynarray_move(ThreadDynarray_t ptr, const unsigned long dst,
132 const unsigned long src, unsigned long count);
134 /* Compare the content of the entry pointed to by index with the content of
135 * the entry addressed by __entry. The function returns true if the contents
138 bool ThreadDynarray_compare(ThreadDynarray_t ptr,
139 const unsigned long index,
140 ThreadEntry_t const __entry);
143 * Returns a reference to a new ThreadDynarray new set is a clone of the self.
145 ThreadDynarray_t ThreadDynarray_clone(ThreadDynarray_t ptr);
148 * Extends the capacity when the container is full.
150 void ThreadDynarray_resize(ThreadDynarray_t ptr);
153 * Returns the number of elements.
155 unsigned long ThreadDynarray_getCount(ThreadDynarray_t ptr);
158 * Returns the current storage capacity of the ThreadDynarray. This is guaranteed
159 * to be at least as large as count().
161 unsigned long ThreadDynarray_getCapacity(ThreadDynarray_t ptr);
164 * Returns upper bound of self (max index).
166 unsigned long ThreadDynarray_getUpperBound(ThreadDynarray_t ptr);
169 * Returns lower bound of self (always zero).
171 unsigned long ThreadDynarray_getLowerBound(ThreadDynarray_t ptr);
174 * Returns the size of the elements.
176 unsigned long ThreadDynarray_getElementSize(ThreadDynarray_t ptr);
179 * Returns true if the size of self is zero.
181 bool ThreadDynarray_isEmpty(ThreadDynarray_t ptr);
184 * Returns true if capacity available.
186 bool ThreadDynarray(ThreadDynarray_t ptr);
189 * Returns true if the container is full.
191 bool ThreadDynarray_is_full(ThreadDynarray_t ptr);
194 * Returns true if capacity available.
196 bool ThreadDynarray_getCapacityAvailable(ThreadDynarray_t ptr);
201 ThreadDynarray_t ThreadDynarray_assign(ThreadDynarray_t src,
202 ThreadDynarray_t dst);
205 * Returns true if the dynamic arrays are equal.
207 bool ThreadDynarray_areEquals(ThreadDynarray_t ptr1,
208 ThreadDynarray_t ptr2);
211 * Returns true if the dynamic arrays are not equal.
213 bool ThreadDynarray_areNotEquals(ThreadDynarray_t ptr1,
214 ThreadDynarray_t ptr2);
216 void ThreadDynarray_lock(ThreadDynarray_t ptr);
218 void ThreadDynarray_unlock(ThreadDynarray_t ptr);
221 #endif /* #ifndef __THREAD_DYNARRAY_H__ */