#include <cel_memory.h>

Public Member Functions | |
| SimpleArray (size_t inSize=0, size_t inReserve=AUTO_SIZE, MemoryAllocator *inAllocator=NULL, size_t inAllocationUnit=0) | |
| SimpleArray (const SimpleArray &inSa) | |
| ~SimpleArray () | |
| void | init (size_t inSize=0, size_t inReserve=0, MemoryAllocator *inAllocator=NULL, size_t inAllocationUnit=0) |
| SimpleArray & | operator= (const SimpleArray &inSa) |
| void | strictCleanup (bool doIt=true) |
| void | setAllocationUnit (size_t inAllocationUnit) |
| size_t | getAllocationUnit () |
| T * | getPtr () |
| const T * | getPtr () const |
| size_t | getSize () const |
| size_t | getReservedSize () const |
| bool | isValid () const |
| T & | operator[] (size_t inPos) |
| const T & | operator[] (size_t inPos) const |
| void | allocate (size_t inSize, size_t inReserve=AUTO_SIZE) |
| void | reserve (size_t inSize) |
| void | reallocate (size_t inSize) |
| void | resize (size_t inSize) |
| void | compact () |
| void | free () |
| void | clear () |
| void | remove (size_t inPos, size_t inCount) |
| void | insert (size_t inPos, size_t inCount) |
| void | insert (size_t inPos, size_t inCount, const T *inElements) |
| void | insert (size_t inPos, const SimpleArray &inElements) |
| void | duplicate (const SimpleArray &inSa, bool inNeedCompaction=false) |
| void | duplicate (const T *inBuffer, size_t inSize) |
| void | duplicate (const T *inBuffer, size_t inSize, Endian inEndian) |
| void | fill (const T &t) |
| template<typename U> | |
| void | fill (const U &u) |
| void | zeroClear () |
| void | swap (SimpleArray &inSa) |
| void | push_back (const T &t) |
| template<typename U> | |
| void | push_back (const U &t) |
| T | pop_back () |
| void | push_front (const T &t) |
| template<typename U> | |
| void | push_front (const U &t) |
| T | pop_front () |
| T * | begin () |
| T * | end () |
| T * | last () |
| const T * | begin () const |
| const T * | end () const |
| const T * | last () const |
| T & | front () |
| const T & | front () const |
| T & | back () |
| const T & | back () const |
std::vector. This class does not need T(const T& t) type constructor but T() .T is simple types such as int, long, ... In these cases, copyPolicy should be changed into byMemcpy. With byMemcpy , copy operations are done with std::memcpy and it may increases the performance of the array operations. byMemcpy is default for the type like int, long ... (types which are called POD).Definition at line 344 of file cel_memory.h.
| Celartem::SimpleArray< T, copyPolicy >::SimpleArray | ( | size_t | inSize = 0, |
|
| size_t | inReserve = AUTO_SIZE, |
|||
| MemoryAllocator * | inAllocator = NULL, |
|||
| size_t | inAllocationUnit = 0 | |||
| ) | [inline] |
This constructor initializes the SimpleArray instance by the specified size; it does almost same as init method.
| inSize | Specifies the size of the array in number of entries. | |
| inReserve | Specifies the reservation size of the array in number of entries. The reservation size is a parameter that controls relocation of the array. Although the larger reservation size assures you of the better speed performance of array resizing until the size surpasses the reservation size, it firstly request the reservation size of memory to the operating system. | |
| inAllocator | Specifies the MemoryAllocator instance that is used to allocate/deallocate memory blocks. It can be NULL and then SimpleArray uses the default allocator. | |
| inAllocationUnit | Specifies the unit size for allocation. For more information, see setAllocationUnit. |
Definition at line 372 of file cel_memory.h.
| Celartem::SimpleArray< T, copyPolicy >::SimpleArray | ( | const SimpleArray< T, copyPolicy > & | inSa | ) | [inline] |
This constructor initializes the SimpleArray instance with the data copied from the other instance.
| inSa | An array to be duplicated. This constructor really copies the memory block held by the instance. |
Definition at line 392 of file cel_memory.h.
| Celartem::SimpleArray< T, copyPolicy >::~SimpleArray | ( | ) | [inline] |
Deletes the array.
Definition at line 402 of file cel_memory.h.
| void Celartem::SimpleArray< T, copyPolicy >::init | ( | size_t | inSize = 0, |
|
| size_t | inReserve = 0, |
|||
| MemoryAllocator * | inAllocator = NULL, |
|||
| size_t | inAllocationUnit = 0 | |||
| ) | [inline] |
This method initializes the SimpleArray instance by the specified size. No other method can replace the allocator except the constructor.
| inSize | Specifies the size of the array in number of entries. | |
| inReserve | Specifies the reservation size of the array in number of entries. The reservation size is a parameter that controls relocation of the array. Although the larger reservation size assures you of the better speed performance of array resizing until the size surpasses the reservation size, it firstly request the reservation size of memory to the operating system. | |
| inAllocator | Specifies the MemoryAllocator instance that is used to allocate/deallocate memory blocks. It can be NULL and then SimpleArray uses the default allocator. | |
| inAllocationUnit | Specifies the unit size for allocation. For more information, see setAllocationUnit. |
Definition at line 431 of file cel_memory.h.
| SimpleArray& Celartem::SimpleArray< T, copyPolicy >::operator= | ( | const SimpleArray< T, copyPolicy > & | inSa | ) | [inline] |
This method copies the specified instance.
| inSa | An array to be duplicated. This constructor really copies the memory block held by the instance. |
Definition at line 451 of file cel_memory.h.
| void Celartem::SimpleArray< T, copyPolicy >::strictCleanup | ( | bool | doIt = true |
) | [inline] |
This method is to control whether the array will be zero-cleared or not in the destruction/reallocation phase. You should do zero-clear of the memory block if you store some sensitive information such as user credential.
| doIt | true to do zero-clear in the destruction/reallocation phase. false to disable zero-clear. |
Definition at line 467 of file cel_memory.h.
Referenced by Celartem::DataArray< T >::duplicate(), Celartem::SimpleArray< Celartem::AutoPtr< Celartem::Image > >::swap(), and Celartem::DataArray< T >::swap().
| void Celartem::SimpleArray< T, copyPolicy >::setAllocationUnit | ( | size_t | inAllocationUnit | ) | [inline] |
This method is to set the memory allocation unit which is used during reallocation calls.
| inAllocationUnit | Specifies the unit size for allocation. This is not the size in bytes but the count of elements. A large value makes reallocate calls faster but result in the larger memory consumption. For use with MemoryStorage, we recommend you should choose a large value for it. 0 means using the default. |
Definition at line 485 of file cel_memory.h.
Referenced by Celartem::SimpleArray< Celartem::AutoPtr< Celartem::Image > >::init(), and Celartem::SimpleArray< Celartem::AutoPtr< Celartem::Image > >::SimpleArray().
| size_t Celartem::SimpleArray< T, copyPolicy >::getAllocationUnit | ( | ) | [inline] |
This method is to obtain the current memory allocation unit.
Definition at line 500 of file cel_memory.h.
| T* Celartem::SimpleArray< T, copyPolicy >::getPtr | ( | ) | [inline] |
This method returns raw pointer to the array.
Definition at line 511 of file cel_memory.h.
Referenced by Celartem::DataArray< T >::getPtr(), and Celartem::DataArray< T >::getVoidPtr().
| const T* Celartem::SimpleArray< T, copyPolicy >::getPtr | ( | ) | const [inline] |
This method returns const raw pointer to the array.
Definition at line 523 of file cel_memory.h.
| size_t Celartem::SimpleArray< T, copyPolicy >::getSize | ( | ) | const [inline] |
This method returns the size of array in number of entries.
Definition at line 535 of file cel_memory.h.
Referenced by Celartem::DataArray< T >::getSize(), Celartem::SimpleArray< Celartem::AutoPtr< Celartem::Image > >::insert(), Celartem::SimpleArray< Celartem::AutoPtr< Celartem::Image > >::pop_back(), Celartem::SimpleArray< Celartem::AutoPtr< Celartem::Image > >::push_back(), and Celartem::DataArray< T >::serialize().
| size_t Celartem::SimpleArray< T, copyPolicy >::getReservedSize | ( | ) | const [inline] |
This method returns the reserved size of array in number of entries.
Definition at line 543 of file cel_memory.h.
| bool Celartem::SimpleArray< T, copyPolicy >::isValid | ( | ) | const [inline] |
This method checks whether the array is valid or not.
true if the array is valid, otherwise false. Definition at line 551 of file cel_memory.h.
Referenced by Celartem::DataArray< T >::isValid().
| T& Celartem::SimpleArray< T, copyPolicy >::operator[] | ( | size_t | inPos | ) | [inline] |
This method provides the array interface.
| inPos | Index to an entry. |
Definition at line 564 of file cel_memory.h.
| const T& Celartem::SimpleArray< T, copyPolicy >::operator[] | ( | size_t | inPos | ) | const [inline] |
This method provides the array interface (for read).
| inPos | Index to an entry. |
Definition at line 577 of file cel_memory.h.
| void Celartem::SimpleArray< T, copyPolicy >::allocate | ( | size_t | inSize, | |
| size_t | inReserve = AUTO_SIZE | |||
| ) | [inline] |
This method allocates the array.
This method firstly frees all the contents on the array and renew the array itself; if you want to keep the contents during the reconstruction of the array, use reallocate or resize.
| inSize | Specifies the size of the array in number of entries. | |
| inReserve | Specifies the reservation size of the array in number of entries. The reservation size is a parameter that controls relocation of the array. Although the larger reservation size assures you of the better speed performance of array resizing until the size surpasses the reservation size, it firstly request the reservation size of memory to the operating system. |
Definition at line 602 of file cel_memory.h.
Referenced by Celartem::DataArray< T >::allocate(), Celartem::DataArray< T >::deserialize(), Celartem::SimpleArray< Celartem::AutoPtr< Celartem::Image > >::duplicate(), Celartem::SimpleArray< Celartem::AutoPtr< Celartem::Image > >::init(), and Celartem::SimpleArray< Celartem::AutoPtr< Celartem::Image > >::SimpleArray().
| void Celartem::SimpleArray< T, copyPolicy >::reserve | ( | size_t | inSize | ) | [inline] |
This method changes the reservation size of the array.
| inSize | Specifies the reservation size of the array in number of entries. The reservation size is a parameter that controls relocation of the array. Although the larger reservation size assures you of the better speed performance of array resizing until the size surpasses the reservation size, it firstly request the reservation size of memory to the operating system. |
Definition at line 624 of file cel_memory.h.
Referenced by Celartem::DataArray< T >::reserve().
| void Celartem::SimpleArray< T, copyPolicy >::reallocate | ( | size_t | inSize | ) | [inline] |
This method reallocates the array. This method keeps the contents on the array during the reconstruction of the array and it is slower than allocate method; if you don't want to keep the contents, use allocate instead.
resize is just an alias of this method and the behavior is identical to this method.
| inSize | Specifies the new size of the array in number of entries. |
Definition at line 641 of file cel_memory.h.
Referenced by Celartem::SimpleArray< Celartem::AutoPtr< Celartem::Image > >::resize(), and Celartem::DataArray< T >::resize().
| void Celartem::SimpleArray< T, copyPolicy >::resize | ( | size_t | inSize | ) | [inline] |
This method reallocates the array. This method is identical to reallocate method. See reallocate for more information.
This method is provided for the compatibility with std::vector.
| inSize | Specifies the new size of the array in number of entries. |
Definition at line 666 of file cel_memory.h.
Referenced by Celartem::Base64T< Base64Traits >::decode(), Celartem::SimpleArray< Celartem::AutoPtr< Celartem::Image > >::pop_back(), and Celartem::SimpleArray< Celartem::AutoPtr< Celartem::Image > >::push_back().
| void Celartem::SimpleArray< T, copyPolicy >::compact | ( | ) | [inline] |
This method reduces memory consumption by deallocating the unused reserved area.
Please note that compaction actually moves the location of the array and it may take relatively long time.
Definition at line 676 of file cel_memory.h.
| void Celartem::SimpleArray< T, copyPolicy >::free | ( | ) | [inline] |
This method releases the memory.
Please note that since this method really deallocates the memory block associated with this SimpleArray instance, it does not keep the reservation size after the call. If you want to preserve the allocated memory for it, use reallocate (0) rather than this method.
Please note that this method keeps the current memory allocation unit. To revert the value to the default, use setAllocationUnit method.
Definition at line 699 of file cel_memory.h.
Referenced by Celartem::SimpleArray< Celartem::AutoPtr< Celartem::Image > >::allocate(), Celartem::SimpleArray< Celartem::AutoPtr< Celartem::Image > >::clear(), Celartem::SimpleArray< Celartem::AutoPtr< Celartem::Image > >::compact(), Celartem::SimpleArray< Celartem::AutoPtr< Celartem::Image > >::duplicate(), Celartem::DataArray< T >::free(), Celartem::DjVu::IFF::Layout::init(), Celartem::SimpleArray< Celartem::AutoPtr< Celartem::Image > >::init(), Celartem::SimpleArray< Celartem::AutoPtr< Celartem::Image > >::insert(), and Celartem::SimpleArray< Celartem::AutoPtr< Celartem::Image > >::~SimpleArray().
| void Celartem::SimpleArray< T, copyPolicy >::clear | ( | ) | [inline] |
This method release the memory.
This is just an alias of free method.
Definition at line 715 of file cel_memory.h.
| void Celartem::SimpleArray< T, copyPolicy >::remove | ( | size_t | inPos, | |
| size_t | inCount | |||
| ) | [inline] |
This method removes elements of the specified range and moves the elements after them toward the front of the array.
| inPos | The index of the first element to remove. | |
| inCount | The number of elements to remove. |
Definition at line 729 of file cel_memory.h.
| void Celartem::SimpleArray< T, copyPolicy >::insert | ( | size_t | inPos, | |
| size_t | inCount | |||
| ) | [inline] |
This method inserts the specified number of elements to the specified position.
| inPos | It indicates the position on which new elements are inserted. | |
| inCount | The number of the new elements. |
Definition at line 751 of file cel_memory.h.
Referenced by Celartem::SimpleArray< Celartem::AutoPtr< Celartem::Image > >::insert(), and Celartem::SimpleArray< Celartem::AutoPtr< Celartem::Image > >::push_front().
| void Celartem::SimpleArray< T, copyPolicy >::insert | ( | size_t | inPos, | |
| size_t | inCount, | |||
| const T * | inElements | |||
| ) | [inline] |
This method inserts the specified number of elements to the specified position.
| inPos | It indicates the position on which new elements are inserted. | |
| inCount | The number of the elements in inElements. | |
| inElements | The elements to insert. |
Definition at line 801 of file cel_memory.h.
| void Celartem::SimpleArray< T, copyPolicy >::insert | ( | size_t | inPos, | |
| const SimpleArray< T, copyPolicy > & | inElements | |||
| ) | [inline] |
This method inserts the specified number of elements to the specified position.
| inPos | It indicates the position on which new elements are inserted. | |
| inElements | The elements to insert. |
Definition at line 817 of file cel_memory.h.
| void Celartem::SimpleArray< T, copyPolicy >::duplicate | ( | const SimpleArray< T, copyPolicy > & | inSa, | |
| bool | inNeedCompaction = false | |||
| ) | [inline] |
This method duplicates the specified array.
| inSa | An array to be duplicated. | |
| inNeedCompaction | Whether compaction (removing reserved area) is needed or not. |
Definition at line 830 of file cel_memory.h.
Referenced by Celartem::DataArray< T >::duplicate(), Celartem::SimpleArray< Celartem::AutoPtr< Celartem::Image > >::operator=(), and Celartem::SimpleArray< Celartem::AutoPtr< Celartem::Image > >::SimpleArray().
| void Celartem::SimpleArray< T, copyPolicy >::duplicate | ( | const T * | inBuffer, | |
| size_t | inSize | |||
| ) | [inline] |
This method duplicates the specified array.
| inBuffer | An array to be duplicated. | |
| inSize | The size of the array. |
Definition at line 849 of file cel_memory.h.
| void Celartem::SimpleArray< T, copyPolicy >::duplicate | ( | const T * | inBuffer, | |
| size_t | inSize, | |||
| Endian | inEndian | |||
| ) | [inline] |
This method duplicates the specified array.
| inBuffer | An array to be duplicated. | |
| inSize | The size of the array. | |
| inEndian | The endianness of the specified buffer. |
Definition at line 866 of file cel_memory.h.
| void Celartem::SimpleArray< T, copyPolicy >::fill | ( | const T & | t | ) | [inline] |
This method is a general version of fill function; fill(0) fills all array with 0.
| t | The value to fill with. |
Definition at line 888 of file cel_memory.h.
Referenced by Celartem::DataArray< T >::fill().
| void Celartem::SimpleArray< T, copyPolicy >::fill | ( | const U & | u | ) | [inline] |
This method is a general version of fill function; fill(0) fills all array with 0.
| t | The value to fill with. |
Definition at line 901 of file cel_memory.h.
| void Celartem::SimpleArray< T, copyPolicy >::zeroClear | ( | ) | [inline] |
This method zero-clears the array in the way of std::memset . This is very dangerous method and you should consider that you should use fill instead of it.
Definition at line 913 of file cel_memory.h.
Referenced by Celartem::DataArray< T >::zeroClear().
| void Celartem::SimpleArray< T, copyPolicy >::swap | ( | SimpleArray< T, copyPolicy > & | inSa | ) | [inline] |
This method swaps the contents of the array with the specified array instance.
| inSa | The SimpleArray instance with which this instance will exchange the contents. |
Definition at line 926 of file cel_memory.h.
Referenced by Celartem::DataArray< T >::swap().
| void Celartem::SimpleArray< T, copyPolicy >::push_back | ( | const T & | t | ) | [inline] |
This method is almost identical to vector::push_back .
| t | Value to add. |
Definition at line 956 of file cel_memory.h.
Referenced by Celartem::SimpleArray< Celartem::AutoPtr< Celartem::Image > >::push_back(), and Celartem::DataArray< T >::push_back().
| void Celartem::SimpleArray< T, copyPolicy >::push_back | ( | const U & | t | ) | [inline] |
This method is almost identical to vector::push_back .
| t | Value to add. |
Definition at line 969 of file cel_memory.h.
| T Celartem::SimpleArray< T, copyPolicy >::pop_back | ( | ) | [inline] |
This method is almost identical to vector::pop_back .
Definition at line 980 of file cel_memory.h.
Referenced by Celartem::DataArray< T >::pop_back().
| void Celartem::SimpleArray< T, copyPolicy >::push_front | ( | const T & | t | ) | [inline] |
This method is almost identical to deque::push_front .
| t | Value to add. |
Definition at line 994 of file cel_memory.h.
Referenced by Celartem::SimpleArray< Celartem::AutoPtr< Celartem::Image > >::push_front().
| void Celartem::SimpleArray< T, copyPolicy >::push_front | ( | const U & | t | ) | [inline] |
This method is almost identical to deque::push_front .
| t | Value to add. |
Definition at line 1006 of file cel_memory.h.
| T Celartem::SimpleArray< T, copyPolicy >::pop_front | ( | ) | [inline] |
This method is almost identical to deque::pop_front .
Please note that this method is much slower than pop_back.
Definition at line 1018 of file cel_memory.h.
| T* Celartem::SimpleArray< T, copyPolicy >::begin | ( | ) | [inline] |
This method is for the compatibility with STL algorithms.
&array[0] . Definition at line 1032 of file cel_memory.h.
Referenced by Celartem::SimpleArray< Celartem::AutoPtr< Celartem::Image > >::front().
| T* Celartem::SimpleArray< T, copyPolicy >::end | ( | ) | [inline] |
This method is for the compatibility with STL algorithms.
&array[array.getSize()] . Definition at line 1045 of file cel_memory.h.
Referenced by Celartem::SimpleArray< Celartem::AutoPtr< Celartem::Image > >::remove().
| T* Celartem::SimpleArray< T, copyPolicy >::last | ( | ) | [inline] |
This method is for the compatibility with STL algorithms.
&array[array.getSize() - 1] . Definition at line 1058 of file cel_memory.h.
Referenced by Celartem::SimpleArray< Celartem::AutoPtr< Celartem::Image > >::back().
| const T* Celartem::SimpleArray< T, copyPolicy >::begin | ( | ) | const [inline] |
This method is for the compatibility with STL algorithms.
&array[0] . Definition at line 1071 of file cel_memory.h.
| const T* Celartem::SimpleArray< T, copyPolicy >::end | ( | ) | const [inline] |
This method is for the compatibility with STL algorithms.
&array[array.getSize()] . Definition at line 1084 of file cel_memory.h.
| const T* Celartem::SimpleArray< T, copyPolicy >::last | ( | ) | const [inline] |
This method is for the compatibility with STL algorithms.
&array[array.getSize() - 1] . Definition at line 1097 of file cel_memory.h.
| T& Celartem::SimpleArray< T, copyPolicy >::front | ( | ) | [inline] |
This method is for the compatibility with STL algorithms.
array[0] . Definition at line 1110 of file cel_memory.h.
| const T& Celartem::SimpleArray< T, copyPolicy >::front | ( | ) | const [inline] |
This method is for the compatibility with STL algorithms.
array[0] . Definition at line 1122 of file cel_memory.h.
| T& Celartem::SimpleArray< T, copyPolicy >::back | ( | ) | [inline] |
This method is for the compatibility with STL algorithms.
array[getSize() - 1] . Definition at line 1134 of file cel_memory.h.
| const T& Celartem::SimpleArray< T, copyPolicy >::back | ( | ) | const [inline] |
This method is for the compatibility with STL algorithms.
array[getSize() - 1] . Definition at line 1146 of file cel_memory.h.