27 # include <dds/toc_util.h> 71 this->
resize(x.core_seq._length);
72 for (
unsigned int i = 0; i < this->core_seq._length; i++)
73 this->core_seq._buffer[i] = x.core_seq._buffer[i];
79 uint32_t
size()
const;
134 const T&
at (uint32_t n)
const;
138 const T&
front ()
const;
142 const T&
back ()
const;
161 typedef struct CoreSeqType
164 unsigned int _maximum;
165 unsigned int _length;
168 unsigned int _item_size;
171 CoreSeqType_t core_seq;
176 INIT_SEQ(this->core_seq);
177 this->core_seq._item_size =
sizeof(T);
183 INIT_SEQ(this->core_seq);
184 this->core_seq._item_size =
sizeof(T);
197 return this->core_seq._size;
202 return this->core_seq._length;
207 return this->core_seq._length;
213 this->core_seq._maximum = n;
218 return this->core_seq._maximum;
224 return (this->core_seq._length == 0)?
true:
false;
237 T * newbuf =
new T[n];
240 this->core_seq._size = n;
241 if (this->core_seq._length > n)
242 this->core_seq._length = n;
244 if (this->core_seq._buffer)
245 for (uint32_t i = 0;i < this->core_seq._length; i++)
246 newbuf[i] = this->core_seq._buffer[i];
247 tmpbuf = this->core_seq._buffer;
248 this->core_seq._buffer = newbuf;
255 this->core_seq._size = 0;
256 this->core_seq._length = 0;
257 tmpbuf = this->core_seq._buffer;
258 this->core_seq._buffer = 0;
269 if (this->core_seq._size == n)
270 this->core_seq._length = n;
277 resize(this->core_seq._length);
284 return this->core_seq._buffer[n];
290 return this->core_seq._buffer[n];
299 template<
class T>
const T&
sequence<T>::back ()
const {
return (*
this)[this->core_seq._length-1]; }
309 this->core_seq._buffer[this->
size()] = v;
310 this->core_seq._length ++;
315 if (this->core_seq._length > 0) this->core_seq._length--;
320 tmp = this->core_seq;
321 this->core_seq = x.core_seq;
326 delete[] this->core_seq._buffer;
327 this->core_seq._buffer = 0;
328 this->core_seq._length = 0;
329 this->core_seq._size = 0;
334 delete[] this->core_seq._buffer;
335 this->core_seq._buffer =
buffer;
336 this->core_seq._length = n;
337 this->core_seq._size = n;
342 T* retval = this->core_seq._buffer;
343 this->core_seq._buffer = NULL;
344 this->core_seq._length = 0;
345 this->core_seq._size = 0;
349 # define CPP_DECLARE_UNBOUNDED_SEQ( type, name ) typedef DDS::sequence<type> name 350 # define DECLARE_CPP_UNBOUNDED_SEQ( type, name ) typedef DDS::sequence<type> name T & front()
Definition: dds_seq.hh:295
T * release()
Release current sequence contents, caller takes ownership of the memory. If successful, the sequence is empty after this operation.
Definition: dds_seq.hh:341
bool empty() const
test if the sequence is empty
Definition: dds_seq.hh:223
uint32_t size() const
Returns the current size (number of elements) of the sequence.
Definition: dds_seq.hh:201
void assign(T *buffer, uint32_t n)
Caller provides an array of elements of size 'n'. The Sequence takes ownership of the memory...
Definition: dds_seq.hh:333
T & back()
Definition: dds_seq.hh:298
uint32_t length() const
alias for size()
Definition: dds_seq.hh:206
Sequence data type.
Definition: dds_seq.hh:55
void clear()
Definition: dds_seq.hh:325
T & operator[](uint32_t n)
Definition: dds_seq.hh:283
~sequence()
destroy the sequence and release resources. Destroys sequence contents.
Definition: dds_seq.hh:189
const T * buffer() const
Definition: dds_seq.hh:300
sequence & operator=(const sequence &x)
assignment operator Copies seqeuence contents.
Definition: dds_seq.hh:70
void pop_back()
Definition: dds_seq.hh:314
Provides the DDS infrastructure.
Definition: dds_builtin_basic.hh:28
void shrink_to_fit()
reduce 'capacity' to match 'size'
Definition: dds_seq.hh:276
bool resize(uint32_t n)
Set the 'capacity' and 'size' of the sequence.
Definition: dds_seq.hh:266
bool reserve(uint32_t n)
Set the capacity of the sequence.
Definition: dds_seq.hh:232
uint32_t maximum() const
set the 'maximum' length of the sequence
Definition: dds_seq.hh:217
uint32_t capacity() const
Returns the current capacity (number of elements) of the sequence. The equation "size <= capacity" is...
Definition: dds_seq.hh:196
sequence()
construct an empty sequence
Definition: dds_seq.hh:175
void push_back(const T &v)
Definition: dds_seq.hh:303
T & at(uint32_t n)
Definition: dds_seq.hh:293
void swap(sequence &x)
Definition: dds_seq.hh:318