opennurbs_fsp_defs.h
1 /* $NoKeywords: $ */
2 /*
3 //
4 // Copyright (c) 1993-2012 Robert McNeel & Associates. All rights reserved.
5 // OpenNURBS, Rhinoceros, and Rhino3D are registered trademarks of Robert
6 // McNeel & Associates.
7 //
8 // THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
9 // ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF
10 // MERCHANTABILITY ARE HEREBY DISCLAIMED.
11 //
12 // For complete openNURBS copyright information see <http://www.opennurbs.org>.
13 //
14 ////////////////////////////////////////////////////////////////
15 */
16 
17 #if !defined(ON_FSP_DEFS_INC_)
18 #define ON_FSP_DEFS_INC_
19 
20 template <class T>
23 {}
24 
25 template <class T>
27 {
29 }
30 
31 template <class T>
33  size_t element_count_estimate,
34  size_t block_element_count
35  )
36 {
37  return ON_FixedSizePool::Create(sizeof(T),element_count_estimate,block_element_count);
38 }
39 
40 template <class T>
42 {
44 }
45 
46 template <class T>
48 {
50 }
51 
52 template <class T>
54 {
56 }
57 
58 template <class T>
60 {
62 }
63 
64 template <class T>
66 {
68 }
69 
70 template <class T>
72 {
74 }
75 
76 template <class T>
78 {
80 }
81 
82 template <class T>
83 T* ON_SimpleFixedSizePool<T>::Element(size_t element_index) const
84 {
85  return (T *)ON_FixedSizePool::Element(element_index);
86 }
87 
88 template <class T>
89 size_t ON_SimpleFixedSizePool<T>::ElementIndex(T* element_ptr) const
90 {
91  return ON_FixedSizePool::ElementIndex(element_ptr);
92 }
93 
94 template <class T>
97 {}
98 
99 template <class T>
101 : ON_FixedSizePoolIterator(fsp_it)
102 {}
103 
104 template <class T>
106 {
108 }
109 
110 
111 template <class T>
113 {
114  return (T *)ON_FixedSizePoolIterator::FirstElement(element_index);
115 }
116 
117 template <class T>
119 {
121 }
122 
123 template <class T>
125 {
127 }
128 
129 
130 template <class T>
132 {
134 }
135 
136 template <class T>
137 T* ON_SimpleFixedSizePoolIterator<T>::FirstBlock( size_t* block_element_count )
138 {
139  return (T *)ON_FixedSizePoolIterator::FirstBlock(block_element_count);
140 }
141 
142 template <class T>
143 T* ON_SimpleFixedSizePoolIterator<T>::NextBlock( size_t* block_element_count )
144 {
145  return (T *)ON_FixedSizePoolIterator::NextBlock(block_element_count);
146 }
147 
148 #endif
size_t SizeofElement() const
Definition: opennurbs_fsp_defs.h:41
T * FirstElement()
Get the first element when iterating through the list of elements.
Definition: opennurbs_fsp_defs.h:105
void Destroy()
Destroy the pool and free all the heap. The pool cannot be used again until Create() is called...
Definition: opennurbs_fsp_defs.h:65
T * AllocateElement()
Definition: opennurbs_fsp_defs.h:47
T * NextBlock(size_t *block_element_count)
Get the next block when iterating through the blocks.
Definition: opennurbs_fsp_defs.h:143
void * CurrentElement() const
void * FirstBlock(size_t *block_element_count)
Get a pointer to the first element in the first block.
ON_SimpleFixedSizePoolIterator(const class ON_SimpleFixedSizePool< T > &fsp)
Definition: opennurbs_fsp_defs.h:95
void * Element(size_t element_index) const
Get the i-th elment in the fixed size pool.
void * NextElement()
Get the next element when iterating through the list of elements. If FirstElement() is not called...
bool Create(size_t element_count_estimate, size_t block_element_count)
Create a fixed size memory pool.
Definition: opennurbs_fsp_defs.h:32
void * NextBlock(size_t *block_element_count)
Get the next block when iterating through the blocks.
size_t ActiveElementCount() const
Definition: opennurbs_fsp_defs.h:71
Definition: opennurbs_fsp.h:19
size_t ElementIndex(const void *element_pointer) const
Get the fixed size pool index of an element.
void ReturnElement(T *p)
Return an element to the pool.
Definition: opennurbs_fsp_defs.h:53
T * Element(size_t element_index) const
Get the i-th elment in the pool.
Definition: opennurbs_fsp_defs.h:83
size_t ActiveElementCount() const
void ReturnAll()
Return all allocated elements to the pool. No heap is freed and the pool remains initialized and read...
Definition: opennurbs_fsp_defs.h:59
void Destroy()
Destroy the pool and free all the heap. The pool cannot be used again until Create() is called...
Definition: opennurbs_fsp.h:411
Definition: opennurbs_fsp.h:548
~ON_SimpleFixedSizePool()
Definition: opennurbs_fsp_defs.h:26
size_t SizeofElement() const
void Reset()
Sets the state of the iterator to the initial state that exists after construction. This is useful if the iterator has been used the get one or more elements and then the referenced fixed size pool is modified or code wants to begin iteration again a used a call to NextElement() to return the first element.
void ReturnAll()
Return all allocated elements to the pool. No heap is freed and the pool remains initialized and read...
ON_SimpleFixedSizePool()
construction ////////////////////////////////////////////////////////
Definition: opennurbs_fsp_defs.h:21
size_t TotalElementCount() const
size_t TotalElementCount() const
Definition: opennurbs_fsp_defs.h:77
void * FirstElement()
Get the first element when iterating through the list of elements.
T * CurrentElement()
Definition: opennurbs_fsp_defs.h:124
size_t ElementIndex(T *) const
Definition: opennurbs_fsp_defs.h:89
void Reset()
Sets the state of the iterator to the initail state that exists after construction. This is useful if the iterator has been used the get one or more elements and then the referenced fixed size pool is modified or code wants to begin iteration again a used a call to NextElement() to return the first element.
Definition: opennurbs_fsp_defs.h:131
Definition: opennurbs_fsp.h:239
void * AllocateElement()
T * NextElement()
Get the next element when iterating through the list of elements. If FirstElement() is not called...
Definition: opennurbs_fsp_defs.h:118
bool Create(size_t sizeof_element, size_t element_count_estimate, size_t block_element_capacity)
Create a fixed size memory pool.
T * FirstBlock(size_t *block_element_count)
Get a pointer to the first element in the first block.
Definition: opennurbs_fsp_defs.h:137
void ReturnElement(void *p)
Return an element to the pool.