#include <type_allocator.h>
Inheritance diagram for type_allocator:

Public Types | |
| typedef T* | iterator |
| An iterator is just a pointer to the object. | |
| typedef const T* | const_iterator |
| An iterator is just a pointer to the object. | |
| typedef T& | reference |
| A reference is a reference to the object. | |
| typedef const T& | const_reference |
| A reference is a reference to the object. | |
| typedef size_t | difference_type |
| The distance between two entries in the list is the longest possible unsigned integer on the platform. | |
Public Methods | |
| iterator | begin () |
| Beginning of elements. More... | |
| const_iterator | begin () const |
| Beginning of elements. More... | |
| iterator | end () |
| One past end of elements. More... | |
| const_iterator | end () const |
| One past end of elements. More... | |
| iterator | last () |
| Last entry in list. More... | |
| const_iterator | last () const |
| Last entry in list. More... | |
| difference_type | distance_ta (const_iterator f, const_iterator s) const |
| Distance between two operands. More... | |
| difference_type | distance_ta (const_iterator p) const |
| Index of entry p in list. More... | |
| size_t | curAllocation () const |
| Return current number of allocated slots. More... | |
| void | erase (iterator s, iterator e) |
| Erase from s to and including e-1. More... | |
| void | erase (iterator p) |
| Erase specified entry. More... | |
| void | uninitialized_copy (const_iterator s, const_iterator e, iterator d) |
| Not a full implementation. More... | |
| void | deleteElements () |
| Free the elements. More... | |
| void | set_exp_alloc () |
| Use the exponential allocator. More... | |
| void | set_block_alloc () |
| Use the block allocator. More... | |
| void | set_justsize_alloc () |
| Size the allocation just to fit. More... | |
| void | reAllocation (T *newElements, size_t nextAlloc, size_t nNext) |
| Reset the element storage to specified values. More... | |
| void | reserve (size_t n) |
| Make sure we have enough storage to hold specified number of elements. More... | |
| void | reserveArray (size_t n) |
| Array reservation. More... | |
| type_allocator () | |
| Empty list. More... | |
| type_allocator (const type_allocator<T, defAlloc>& fl) | |
| Copy specified list. | |
| type_allocator<T, defAlloc>& | operator= (const type_allocator<T, defAlloc>& fl) |
| Simply copy operand into list. More... | |
| ~type_allocator () | |
| Delete element storage. More... | |
| void | destroy_obj () |
| So can put type allocators in type allocator lists on machines with compilers that do not understand ~T();. | |
| int | empty () const |
| Is the list empty? More... | |
| size_t | size () const |
| Return number of elements in list. More... | |
| void | setNElements (size_t n) |
| Set the number of elements to specified value. More... | |
| iterator | find (const T& id) |
| Find given object in list. More... | |
| iterator | find (iterator s, iterator e, const T& id) |
| Find given object in list within given range. More... | |
| const_iterator | find (const T& id) const |
| Find given object in list. More... | |
| const_iterator | find (const_iterator s, const_iterator e, const T& id) const |
| Find given object in list within given range. More... | |
| size_t | nextAllocation (size_t n) const |
| Compute the next allocation size that will fit requested allocation if requested size is greater than current allocation. More... | |
| iterator | insert (const T& id) |
| Insert object at end of list. More... | |
| iterator | add (const T& id) |
| iterator | insert (iterator position, const T& id) |
| Insert object at specified position. More... | |
| int | sortBy (int (*comparison)(const void *a, const void *b)) |
| Sort the entire list by the comparison function using qsort. More... | |
| int | sortBy (const_iterator s, const_iterator e, int (*comparison)(const void *a, const void *b)) |
| Sort list between given start and end by the comparison function using qsort. More... | |
| int | makeuniq (int (*comparison)(const void *a, const void *b)) |
| Make the entries in type_allocator unique by sorting the list then removing duplicate entires. More... | |
| int | makeuniq (iterator s, iterator e, int (*comparison)(const void *a, const void *b)) |
| Make the entries in type_allocator unique by sorting the list then removing duplicate entires. More... | |
| T& | operator[] (size_t i) |
| Return reference to object at specified index. More... | |
| const T& | operator[] (size_t i) const |
| Return reference to object at specified index. More... | |
Friends | |
| int | operator== (const type_allocator<T, defAlloc>& iA, const type_allocator<T, defAlloc>& iB) |
| So that type allocator lists can be part of other lists. | |
Template class must include type for list to hold and the number of elements to be held on the stack. Once users add more objects than the default initial size, the storage is dynamically created to hold the members. Any object that implements a default constructor, a copy constructor, and equal operator, a destructor, and an equality operator can be put into type_allocator lists. Note that since C++ constructs default constructors, only the equal operator and the equality operator are required. A small note: There are a number of methods that are duplicates of one another except one has the signature of const and the other does not. The code needs to be replicated because casts from non-const arguments to const arguments (or visa versa) is not symantically correct and certain compilers might make incorrect assumptions in compiling the code.
example_uns_ftn.f, exmesh_impl.cxx, exuns_impl.cxx, nodetonode.cxx, OpenGateway.C, OpenGatewayBase.C, readexuns_ftn.f, test_blk.C, test_blkinter.C, vector1.cxx, vector2.cxx, and vector3.cxx.
|
||||
|
Empty list. By default use exponential allocator. |
|
||||
|
Delete element storage. DO NOT make virtual because this is a template class. All subclasses that use a list as parent class must explicitly carry out destructor by invoking it explicitly.
|
|
||||
|
Beginning of elements.
|
|
||||
|
Beginning of elements.
|
|
||||
|
One past end of elements.
|
|
||||
|
One past end of elements.
|
|
||||
|
Last entry in list.
|
|
||||
|
Last entry in list.
|
|
||||||
|
Distance between two operands.
|
|
||||
|
Index of entry p in list. Invokes distance_ts(const_iterator, const_iterator) with starting entry specified as the beginning of the list.
|
|
||||
|
Return current number of allocated slots.
|
|
||||||
|
Erase from s to and including e-1.
Reimplemented in hashtable. |
|
||||
|
Erase specified entry.
Reimplemented in hashtable. |
|
||||||||
|
Not a full implementation. Uses equality operator instead of new operator with specified space and copy constructor.
|
|
||||
|
Free the elements. If not on stack, then delete all dynamically allocated elements and set storage to stack. If in stack, then just erase all elements. |
|
||||
|
Use the exponential allocator. At least a factor of two more memory than required will be allocated for the list on any resize request.
|
|
||||
|
Use the block allocator. Allocate block in multiples of the stack allocation if the list needs more memory.
|
|
||||
|
Size the allocation just to fit. The list will be sized to hold only the amount of memory requested. Further inserts into the list imply resizing the list once the stack size has been exhausted. |
|
||||||||
|
Reset the element storage to specified values.
|
|
||||
|
Make sure we have enough storage to hold specified number of elements.
|
|
||||
|
Array reservation. In addition to reserving the space, also sets the number of elements to specified allocation size.
|
|
||||
|
Simply copy operand into list. Note on HP compilers, need to do copy by hand due to compiler bug.
|
|
||||
|
Is the list empty?
|
|
||||
|
Return number of elements in list.
|
|
||||
|
Set the number of elements to specified value.
|
|
||||
|
Find given object in list. If not found, return end().
Reimplemented in hashtable.
|
|
||||||||
|
Find given object in list within given range. If not found, return e.
|
|
||||
|
Find given object in list. If not found, return end().
Reimplemented in hashtable. |
|
||||||||
|
Find given object in list within given range. If not found, return e.
|
|
||||
|
Compute the next allocation size that will fit requested allocation if requested size is greater than current allocation. If exponential allocator, then we will at least double the current allocation by defAlloc blocks of storage. Block allocation just uses nearest multiple of defAlloc to size requested. Just to fit simply uses the requested size.
|
|
||||
|
Insert object at end of list.
Reimplemented in hash_link, and hashtable.
|
|
||||||
|
Insert object at specified position.
|
|
||||
|
Sort the entire list by the comparison function using qsort. Warning: Objects can only hold POD (plain old data). Does not properly carry out equal operation when moving data around because uses qsort directly. Proper qsort implementation for objects for future.
|
|
||||||||
|
Sort list between given start and end by the comparison function using qsort. Warning: Objects can only hold POD (plain old data). Does not properly carry out equal operation when moving data around because uses qsort directly. Proper qsort implementation for objects for future.
|
|
||||
|
Make the entries in type_allocator unique by sorting the list then removing duplicate entires. See sortBy() for restrictions on the type of objects that can be in the list.
|
|
||||||||
|
Make the entries in type_allocator unique by sorting the list then removing duplicate entires. See sortBy() for restrictions on the type of objects that can be in the list.
|
|
||||
|
Return reference to object at specified index.
|
|
||||
|
Return reference to object at specified index.
|
1.2.0 written by Dimitri van Heesch,
© 1997-2000