#include <BaseArray.h>
Public Member Functions | |
BaseArray () | |
Constructor. | |
SizeType | GetSize (void) |
Return array size. | |
bool | IsEmpty (void) |
Return whether the array is empty or not. | |
bool | Clear () |
Clear array. | |
DataType & | At (SizeType pos) |
Return reference of item at specified position NB! For speed purposes does not check constraints! | |
Protected Member Functions | |
bool | Resize (const SizeType size, const DataType &values=DataType()) |
Resize array to certain length. | |
bool | Add (const DataType &value) |
Add item to the end of array. | |
bool | Insert (const DataType &value, const SizeType pos) |
Insert item to the pos. | |
bool | Remove (const SizeType pos) |
Remove item at pos. | |
Protected Attributes | |
ListType | data |
SizeType | current_size |
Definition at line 52 of file BaseArray.h.
AVRCpp::Collection::BaseArray< DataType, SizeType, ListType >::BaseArray | ( | ) | [inline] |
Constructor.
Definition at line 137 of file BaseArray.h.
00138 { 00139 this->current_size = 0; 00140 }
bool AVRCpp::Collection::BaseArray< DataType, SizeType, ListType >::Resize | ( | const SizeType | size, | |
const DataType & | values = DataType() | |||
) | [inline, protected] |
Resize array to certain length.
Reimplemented in AVRCpp::Collection::DynamicArray< DataType, SizeType, array_capacity, reserve_size, block_size >, and AVRCpp::Collection::StaticArray< DataType, SizeType, array_capacity >.
Definition at line 61 of file BaseArray.h.
00062 { 00063 // Fill new sections with default value 00064 for (register SizeType index = this->current_size; index < size; index++) 00065 { 00066 this->data[index] = values; 00067 } 00068 00069 this->current_size = size; 00070 00071 return true; 00072 }
bool AVRCpp::Collection::BaseArray< DataType, SizeType, ListType >::Add | ( | const DataType & | value | ) | [inline, protected] |
Add item to the end of array.
Reimplemented in AVRCpp::Collection::DynamicArray< DataType, SizeType, array_capacity, reserve_size, block_size >, and AVRCpp::Collection::StaticArray< DataType, SizeType, array_capacity >.
Definition at line 77 of file BaseArray.h.
00078 { 00079 // Increase size and add item 00080 this->data[this->current_size++] = value; 00081 00082 return true; 00083 }
bool AVRCpp::Collection::BaseArray< DataType, SizeType, ListType >::Insert | ( | const DataType & | value, | |
const SizeType | pos | |||
) | [inline, protected] |
Insert item to the pos.
Reimplemented in AVRCpp::Collection::DynamicArray< DataType, SizeType, array_capacity, reserve_size, block_size >, and AVRCpp::Collection::StaticArray< DataType, SizeType, array_capacity >.
Definition at line 88 of file BaseArray.h.
00089 { 00090 // Shift data to right when adding to middle 00091 if (pos < this->current_size) 00092 { 00093 for (register SizeType index = this->current_size; index > pos; index--) 00094 { 00095 this->data[index] = this->data[index - 1]; 00096 } 00097 } 00098 00099 // Increase size 00100 this->current_size++; 00101 this->data[pos] = value; 00102 00103 return true; 00104 }
bool AVRCpp::Collection::BaseArray< DataType, SizeType, ListType >::Remove | ( | const SizeType | pos | ) | [inline, protected] |
Remove item at pos.
Reimplemented in AVRCpp::Collection::DynamicArray< DataType, SizeType, array_capacity, reserve_size, block_size >, and AVRCpp::Collection::StaticArray< DataType, SizeType, array_capacity >.
Definition at line 109 of file BaseArray.h.
00110 { 00111 // Check constraints 00112 if (pos >= this->current_size) 00113 { 00114 return false; 00115 } 00116 00117 // Shift data to left when removing from middle 00118 if (pos < this->current_size - 1) 00119 { 00120 for (register SizeType index = pos + 1; index < this->current_size; index++) 00121 { 00122 this->data[index - 1] = this->data[index]; 00123 } 00124 } 00125 00126 // Decrease size 00127 this->current_size--; 00128 00129 return true; 00130 }
SizeType AVRCpp::Collection::BaseArray< DataType, SizeType, ListType >::GetSize | ( | void | ) | [inline] |
Return array size.
Definition at line 145 of file BaseArray.h.
00146 { 00147 return this->current_size; 00148 }
bool AVRCpp::Collection::BaseArray< DataType, SizeType, ListType >::IsEmpty | ( | void | ) | [inline] |
bool AVRCpp::Collection::BaseArray< DataType, SizeType, ListType >::Clear | ( | ) | [inline] |
Clear array.
Reimplemented in AVRCpp::Collection::DynamicArray< DataType, SizeType, array_capacity, reserve_size, block_size >.
Definition at line 161 of file BaseArray.h.
00162 { 00163 this->current_size = 0; 00164 00165 return true; 00166 }
DataType& AVRCpp::Collection::BaseArray< DataType, SizeType, ListType >::At | ( | SizeType | pos | ) | [inline] |
Return reference of item at specified position NB! For speed purposes does not check constraints!
Definition at line 172 of file BaseArray.h.
00173 { 00174 return this->data[pos]; 00175 }
ListType AVRCpp::Collection::BaseArray< DataType, SizeType, ListType >::data [protected] |
Definition at line 55 of file BaseArray.h.
SizeType AVRCpp::Collection::BaseArray< DataType, SizeType, ListType >::current_size [protected] |
Definition at line 56 of file BaseArray.h.
MTÜ TTÜ Robotiklubi |