|
|
|
|
|
|
|
|
|
|
|
|||||||
#include <stlsoft_auto_buffer.h>
Attributes | |
| size_type | size () const |
| Returns the number of elements in the auto_buffer. | |
| ss_bool_t | empty () const |
| Indicates whether the buffer has any contents. | |
| size_type | internal_size () |
| Returns the number of elements in the auto_buffer's internal buffer. | |
Public Types | |
Types | |
| typedef T | value_type |
| The value type. | |
| typedef A | allocator_type |
| The allocator type. | |
| typedef auto_buffer< T, A, space > | class_type |
| The type of the current parameterisation. | |
| typedef allocator_type::reference | reference |
| The reference type. | |
| typedef allocator_type::const_reference | const_reference |
| The non-mutable (const) reference type. | |
| typedef allocator_type::pointer | pointer |
| The pointer type. | |
| typedef allocator_type::const_pointer | const_pointer |
| The non-mutable (const) pointer type. | |
| typedef ss_size_t | size_type |
| The size type. | |
| typedef ss_ptrdiff_t | difference_type |
| The difference type. | |
| typedef pointer_iterator< value_type, pointer, reference >::iterator_type | iterator |
| The iterator type. | |
| typedef pointer_iterator< value_type const, const_pointer, const_reference >::iterator_type | const_iterator |
| The non-mutating (const) iterator type. | |
| typedef reverse_iterator_base< iterator, value_type, reference, pointer, difference_type > | reverse_iterator |
| The mutating (non-const) reverse iterator type. | |
| typedef const_reverse_iterator_base< const_iterator, value_type const, const_reference, const_pointer, difference_type > | const_reverse_iterator |
| The non-mutating (const) reverse iterator type. | |
| enum | { space = SPACE } |
Public Methods | |
Construction | |
| auto_buffer (size_type cItems) | |
| Constructs an auto_buffer with the given number of elements. | |
| ~auto_buffer () | |
| Releases the allocated element array. | |
Operations | |
| ss_bool_t | resize (size_type cItems) |
| Expands or contracts the number of items in the buffer. | |
| void | swap (class_type &rhs) |
| Swaps contents with the given buffer. | |
Operators | |
| operator pointer () | |
| An implicit conversion to a pointer to the start of the element array. | |
Accessors | |
| pointer | data () |
| Returns a pointer to the element array. | |
| const_pointer | data () const |
| Returns a pointer-to-const to the element array. | |
Iteration | |
| const_iterator | begin () const |
| Returns a non-mutating iterator representing the start of the sequence. | |
| const_iterator | end () const |
| Returns a non-mutating iterator representing the end of the sequence. | |
| iterator | begin () |
| Returns a mutable iterator representing the start of the sequence. | |
| iterator | end () |
| Returns a mutable iterator representing the end of the sequence. | |
| const_reverse_iterator | rbegin () const |
| Begins the reverse iteration. | |
| const_reverse_iterator | rend () const |
| Ends the reverse iteration. | |
| reverse_iterator | rbegin () |
| Begins the reverse iteration. | |
| reverse_iterator | rend () |
| Ends the reverse iteration. | |
This class provides an efficient replacement for dynamic memory block allocation when the block size generally falls under a certain limit. In such cases, significant performance benefits can be achieved by using an instance of a parameterisation of auto_buffer, whose size parameter SPACE is set to a level to cater for most of the requested sizes. Only where the size of the buffer needs to be larger than this limit does an allocation occur from the heap/free-store via the given allocator.
| T | The type of the elements in the array |
| A | The allocator type |
| SPACE | The number of elements in the array. With translators that support default template arguments, this is defaulted to 256 |
|
|
The allocator type.
|
|
|
The type of the current parameterisation.
|
|
|
The non-mutating (const) iterator type.
|
|
|
The non-mutable (const) pointer type.
|
|
|
The non-mutable (const) reference type.
|
|
|
The non-mutating (const) reverse iterator type.
|
|
|
The difference type.
|
|
|
The iterator type.
|
|
|
The pointer type.
|
|
|
The reference type.
|
|
|
The mutating (non-const) reverse iterator type.
|
|
|
The size type.
|
|
|
The value type.
|
|
|
|
|
|
Constructs an auto_buffer with the given number of elements. Constructs an auto_buffer with the given number of elements. If the allocation fails by throwing an exception, that exception is passed through to the caller. If allocation fails by returning a null pointer the auto_buffer instance is correctly constructed, and the size() method returns 0.
|
|
|
Releases the allocated element array. Releases any allocated memory. If the internal memory buffer was used, then nothing is done, otherwise the allocated memory is returned to the allocator. |
|
|
Returns a mutable iterator representing the start of the sequence.
|
|
|
Returns a non-mutating iterator representing the start of the sequence.
|
|
|
Returns a pointer-to-const to the element array.
|
|
|
Returns a pointer to the element array.
|
|
|
Indicates whether the buffer has any contents.
|
|
|
Returns a mutable iterator representing the end of the sequence.
|
|
|
Returns a non-mutating iterator representing the end of the sequence.
|
|
|
Returns the number of elements in the auto_buffer's internal buffer.
|
|
|
An implicit conversion to a pointer to the start of the element array.
|
|
|
Begins the reverse iteration.
|
|
|
Begins the reverse iteration.
|
|
|
Ends the reverse iteration.
|
|
|
Ends the reverse iteration.
|
|
|
Expands or contracts the number of items in the buffer.
|
|
|
Returns the number of elements in the auto_buffer.
|
|
|
Swaps contents with the given buffer.
|
|
|
| STLSoft Libraries documentation © Synesis Software Pty Ltd, 2001-2004 |