Develop Biology
The language of life
bio::Container Class Reference

#include <Container.h>

+ Inheritance diagram for bio::Container:
+ Collaboration diagram for bio::Container:

Public Member Functions

 Container (const Container &other)
 
 Container (const Index expectedSize=2, std::size_t stepSize=sizeof(ByteStream))
 
virtual ~Container ()
 
virtual ByteStream Access (const Index index)
 
virtual const ByteStream Access (const Index index) const
 
ByteStream Access (const SmartIterator itt)
 
virtual const ByteStream Access (const SmartIterator itt) const
 
virtual Index Add (const ByteStream content)
 
template<typename T >
std::vector< T > AsVector () const
 
virtual SmartIterator Begin () const
 
virtual void Clear ()
 
virtual IteratorConstructClassIterator (const Index index=InvalidIndex()) const
 
virtual SmartIterator End () const
 
bool Erase (const SmartIterator itt)
 
virtual bool Erase (Index index)
 
virtual void Expand ()
 
virtual Index GetAllocatedSize () const
 
virtual Index GetBeginIndex () const
 
virtual Index GetCapacity () const
 
virtual Index GetEndIndex () const
 
virtual Index GetNumberOfElements () const
 
bool Has (const ByteStream content) const
 
virtual void Import (const Container *other)
 
virtual Index Insert (const ByteStream content, const Index index)
 
virtual bool IsAllocated (const Index index) const
 
virtual bool IsFree (const Index index) const
 
virtual bool IsInRange (const Index index) const
 
virtual ByteStream operator[] (const Index index)
 
virtual const ByteStream operator[] (const Index index) const
 
virtual ByteStream operator[] (const SmartIterator itt)
 
virtual const ByteStream operator[] (const SmartIterator itt) const
 
Index SeekTo (const ByteStream content) const
 

Protected Member Functions

virtual bool AreEqual (Index internal, const ByteStream external) const
 
virtual Index GetNextAvailableIndex ()
 
virtual const std::size_t GetStepSize () const
 

Protected Attributes

std::deque< Indexm_deallocated
 
Index m_firstFree
 
Index m_size
 
unsigned char * m_store
 
Iteratorm_tempItt
 

Detailed Description

Containers are the singular Biology container construct. Essentially we need a generic, non-template std::vector<> base class, so we'll make our own. Different containers (e.g. the corollaries to std::set vs std::map vs std::vector) are all children of *this and we use typical inheritance to modify the behavior of each specialization. By using inheritance for our Containers, we can pass Container*s around and use a standard interface to manipulate the contents. In other words, we can treat std::sets like std::vectors or even treat std::maps like std::queues, all by overriding virtual methods and handling inputs consistently (obviously containers with key value pairs will need to pull a new piece of information from somewhere if given only a key or only a value).

NOTE: we still use stl containers where the additional features of *this class are not needed. Those usages may be changed to implement *this in a future release.

You can think of Containers as our own internal RAM. We allocated a block of bytes and manipulate them as necessary. By default, we use ByteStreams to store arbitrary data in our allocated memory. ByteStreams can be wasteful though (e.g. a whole extra std::string for every Index); so, overrides of this can use the same internal memory block but store other data structures for more efficient memory usage. We maintain ByteStreams as our data conversion type, as they are flexible but safer than a void.

When using Containers, we make no guarantees regarding the type of data stored. All we provide is a consistent means of accessing those data. To this end, we ensure that a Index's validity follows the lifecycle of the datum at that Index. This is identical to pointers: a Index represents the memory address of what is stored in *this. This means that as data are erased from *this, the memory is not moved, consolidated, or manipulated in any way that destroys the old references. This rule does have some exceptions and you are allowed to break it yourself. However, we try to stick by this as much as possible (e.g. see Insert(), below).

When using an Iterator, you will be given a SmartIterator which dynamically determines its implementation. Thus, we allow for full inheritance of *this base class.

There is another tradeoff here that we are leaning into: our interface does not make for easy use of std:: containers under-the-hood. By enforcing consistency on access, we've made the system less flexible. This may be changed in a major release down the road but its what we're sticking with for now.

When using Containers there are a few guidelines we recommend:

  1. If you need direct access to the memory stored, store a pointer. Keep it simple.
  2. If you do not need direct access, store the raw type (e.g. for .?int\d+_t types)
  3. Containers themselves should be passed by pointer. This consistency helps when the Container needs to be Cast, etc.

Definition at line 61 of file Container.h.

Constructor & Destructor Documentation

◆ Container() [1/2]

bio::Container::Container ( const Index  expectedSize = 2,
std::size_t  stepSize = sizeof(ByteStream) 
)

NOTE: We cannot use GetStepSize() here as virtual functions are not available to ctors.

Definition at line 29 of file Container.cpp.

33 :
34 m_firstFree(1),
35 m_size(expectedSize + 1),
36 m_tempItt(NULL)
37{
38 m_store = (unsigned char*)std::malloc(m_size * stepSize);
40}
#define BIO_ASSERT(cond)
Definition: AssertMacros.h:29
unsigned char * m_store
Definition: Container.h:340
Index m_firstFree
Definition: Container.h:343
Iterator * m_tempItt
Definition: Container.h:350

References BIO_ASSERT, m_size, and m_store.

◆ Container() [2/2]

bio::Container::Container ( const Container other)

Copy ctor. Imports all contents from other into *this.

Parameters
other

Definition at line 42 of file Container.cpp.

43 :
44 m_firstFree(other.m_firstFree),
45 m_size(other.m_size),
46 m_tempItt(NULL)
47{
48 m_store = (unsigned char*)std::malloc(m_size * other.GetStepSize());
50 Import(&other); // <- NOT VIRTUAL (in ctor).
51}
virtual void Import(const Container *other)
Definition: Container.cpp:251

References BIO_ASSERT, GetStepSize(), Import(), m_size, and m_store.

◆ ~Container()

bio::Container::~Container ( )
virtual

Definition at line 53 of file Container.cpp.

54{
55 Clear(); // <- NOT VIRTUAL (in dtor).
56 if (m_tempItt)
57 {
58 delete m_tempItt;
59 m_tempItt = NULL;
60 }
61 std::free(m_store);
62}
virtual void Clear()
Definition: Container.cpp:265

References Clear(), m_store, and m_tempItt.

Member Function Documentation

◆ Access() [1/4]

ByteStream bio::Container::Access ( const Index  index)
virtual

Get access to an element. NOTE: THIS DOES NOT CHECK IF THE ELEMENT IsFree!!! Free checks can be done independently. This is done for speed.

Parameters
index
Returns
the value stored in *this at the given index.

Reimplemented in bio::physical::Arrangement< TYPE >, bio::physical::Arrangement< Linear >, bio::physical::Arrangement< Bond * >, and bio::physical::Line.

Definition at line 185 of file Container.cpp.

186{
187 BIO_SANITIZE(IsAllocated(index), ,
188 return NULL)
189 ByteStream* ret;
190 std::memcpy(
191 ret,
192 &m_store[index * sizeof(ByteStream)],
193 sizeof(ByteStream));
194 return *ret;
195}
#define BIO_SANITIZE(test, success, failure)
virtual bool IsAllocated(const Index index) const
Definition: Container.cpp:107

References BIO_SANITIZE, IsAllocated(), and m_store.

Referenced by Access(), bio::chemical::UnorderedMotif< CONTENT_TYPE >::AddImplementation(), AreEqual(), bio::Iterator::operator*(), operator[](), and bio::chemical::UnorderedMotif< CONTENT_TYPE >::RemoveImplementation().

◆ Access() [2/4]

const ByteStream bio::Container::Access ( const Index  index) const
virtual

Get access to an element. NOTE: THIS DOES NOT CHECK IF THE ELEMENT IsFree!!! Free checks can be done independently. This is done for speed.

Parameters
index
Returns
the value stored in *this at the given index.

Reimplemented in bio::physical::Arrangement< TYPE >, bio::physical::Arrangement< Linear >, bio::physical::Arrangement< Bond * >, and bio::physical::Line.

Definition at line 197 of file Container.cpp.

198{
199 BIO_SANITIZE(IsAllocated(index), ,
200 return NULL)
201 ByteStream* ret;
202 std::memcpy(
203 ret,
204 &m_store[index * sizeof(ByteStream)],
205 sizeof(ByteStream));
206 return *ret;
207}

References BIO_SANITIZE, IsAllocated(), and m_store.

◆ Access() [3/4]

ByteStream bio::Container::Access ( const SmartIterator  itt)
inline

Access wrapper for SmartIterators.

Parameters
itt
Returns
the value stored in *this at the given index.

Definition at line 183 of file Container.h.

184 {
185 return Access(itt.GetIndex());
186 }
virtual ByteStream Access(const Index index)
Definition: Container.cpp:185

References Access(), and bio::SmartIterator::GetIndex().

◆ Access() [4/4]

virtual const ByteStream bio::Container::Access ( const SmartIterator  itt) const
inlinevirtual

Access wrapper for SmartIterators.

Parameters
itt
Returns
the value stored in *this at the given index.

Definition at line 193 of file Container.h.

194 {
195 return Access(itt.GetIndex());
196 }

References Access(), and bio::SmartIterator::GetIndex().

◆ Add()

Index bio::Container::Add ( const ByteStream  content)
virtual

Adds content to *this.

Parameters
content
Returns
the Index of the added content.

Reimplemented in bio::physical::Arrangement< TYPE >, bio::physical::Arrangement< Linear >, and bio::physical::Arrangement< Bond * >.

Definition at line 129 of file Container.cpp.

130{
132 BIO_SANITIZE(ret, ,
133 return ret)
134 std::memcpy(
135 &m_store[ret * sizeof(ByteStream)],
136 content,
137 sizeof(ByteStream));
138 return ret;
139}
virtual Index GetNextAvailableIndex()
Definition: Container.cpp:329
uint32_t Index
Definition: Types.h:57

References BIO_SANITIZE, GetNextAvailableIndex(), and m_store.

Referenced by bio::chemical::UnorderedMotif< CONTENT_TYPE >::AddImplementation(), bio::chemical::LinearMotif< CONTENT_TYPE >::AddImplementation(), Import(), Insert(), and bio::chemical::LinearMotif< CONTENT_TYPE >::InsertImplementation().

◆ AreEqual()

bool bio::Container::AreEqual ( Index  internal,
const ByteStream  external 
) const
protectedvirtual

To make comparisons easier and reduce the work needed to optimize *this, children can define a comparison method which will be used for all searches.

Parameters
internal
external
Returns
whether or not the contents of *this at the given Index match the given datum.

Reimplemented in bio::physical::Arrangement< TYPE >, bio::physical::Arrangement< Linear >, bio::physical::Arrangement< Bond * >, and bio::physical::Line.

Definition at line 345 of file Container.cpp.

349{
350 return Access(internal) == external;
351}

References Access().

Referenced by SeekTo().

◆ AsVector()

template<typename T >
std::vector< T > bio::Container::AsVector ( ) const
inline

Ease of use wrapper around casting *this to a std::vector. Since template methods are not virtual, you must make sure to properly implement Access() and make sure that *this contains the given type.

Template Parameters
T
Returns
a std::vector containing the contents from *this.

Definition at line 297 of file Container.h.

298 {
299 std::vector< T > ret;
300 for (
301 SmartIterator rct = End();
302 !rct.IsAtBeginning();
303 --rct
304 )
305 {
306 ret.push_back(rct.As< T >());
307 }
308 return ret;
309 }
virtual SmartIterator End() const
Definition: Container.cpp:302
bool IsAtBeginning() const

References End(), and bio::SmartIterator::IsAtBeginning().

◆ Begin()

SmartIterator bio::Container::Begin ( ) const
virtual

NOTE: This does not need to be overridden if you've already defined ConstructClassIterator().

Returns
A new Iterator pointing to the beginning of *this.

Definition at line 295 of file Container.cpp.

296{
297 return SmartIterator(
298 this,
299 GetBeginIndex());
300}
virtual Index GetBeginIndex() const
Definition: Container.cpp:64

References GetBeginIndex().

Referenced by bio::organic::Habitat::AdaptInhabitants(), bio::cellular::Tissue::DifferentiateCells(), bio::chemical::UnorderedMotif< CONTENT_TYPE >::GetStringFromImplementation(), bio::organic::Organism::Morphogenesis(), bio::cellular::OrganSystem::Organogenesis(), bio::chemical::Axis::Rotate(), and bio::cellular::Organ::SpecializeTissues().

◆ Clear()

void bio::Container::Clear ( )
virtual

Remove all elements from *this.

Definition at line 265 of file Container.cpp.

266{
267 //Call destructors before clearing the array.
268 if (!m_tempItt)
269 {
271 }
273 for (
275 --m_tempItt
276 )
277 {
279 }
280
281 m_firstFree = 1;
282 m_deallocated.clear();
283}
std::deque< Index > m_deallocated
Definition: Container.h:344
virtual bool Erase(Index index)
Definition: Container.cpp:237
virtual Iterator * ConstructClassIterator(const Index index=InvalidIndex()) const
Definition: Container.cpp:285
virtual Index GetEndIndex() const
Definition: Container.cpp:69
bool MoveTo(const Index index)
Definition: Iterator.cpp:48
virtual bool IsAtBeginning() const
Definition: Iterator.cpp:58
Index GetIndex() const
Definition: Iterator.cpp:43

References ConstructClassIterator(), Erase(), GetEndIndex(), bio::Iterator::GetIndex(), bio::Iterator::IsAtBeginning(), m_deallocated, m_firstFree, m_tempItt, and bio::Iterator::MoveTo().

Referenced by ~Container(), bio::chemical::LinearMotif< CONTENT_TYPE >::~LinearMotif(), bio::chemical::LinearMotif< CONTENT_TYPE >::ClearImplementation(), and bio::chemical::UnorderedMotif< CONTENT_TYPE >::ClearImplementation().

◆ ConstructClassIterator()

Iterator * bio::Container::ConstructClassIterator ( const Index  index = InvalidIndex()) const
virtual

Override this to construct Iterators for your Containers.

Parameters
index
Returns
a new Iterator pointing to the given Index in *this or NULL.

Definition at line 285 of file Container.cpp.

286{
287 BIO_SANITIZE(IsAllocated(index), ,
288 return NULL)
289 return new Iterator(
290 this,
291 index
292 );
293}

References BIO_SANITIZE, and IsAllocated().

Referenced by Clear(), SeekTo(), bio::physical::Line::SeekToId(), and bio::physical::Line::SeekToName().

◆ End()

◆ Erase() [1/2]

bool bio::Container::Erase ( const SmartIterator  itt)
inline

Erase wrapper for SmartIterators.

Parameters
itt
Returns
whether or not the erasure was successful.

Definition at line 223 of file Container.h.

224 {
225 return Erase(itt.GetIndex());
226 }

References Erase(), and bio::SmartIterator::GetIndex().

◆ Erase() [2/2]

bool bio::Container::Erase ( Index  index)
virtual

Removes content from *this.

Parameters
index
Returns
whether or not the erasure was successful.

Reimplemented in bio::physical::Arrangement< TYPE >, bio::physical::Arrangement< Linear >, and bio::physical::Arrangement< Bond * >.

Definition at line 237 of file Container.cpp.

238{
239 BIO_SANITIZE(IsAllocated(index), ,
240 return false)
241 ByteStream* toDelete;
242 std::memcpy(
243 toDelete,
244 &m_store[index * sizeof(ByteStream)],
245 sizeof(ByteStream));
246 delete toDelete;
247 m_deallocated.push_back(index);
248 return true;
249}

References BIO_SANITIZE, IsAllocated(), m_deallocated, and m_store.

Referenced by Clear(), Erase(), bio::chemical::LinearMotif< CONTENT_TYPE >::InsertImplementation(), and bio::chemical::UnorderedMotif< CONTENT_TYPE >::RemoveImplementation().

◆ Expand()

void bio::Container::Expand ( )
virtual

Grow store to accommodate dynamic allocation.

Parameters
datumSizethe memory size a Index should jump over.

Definition at line 112 of file Container.cpp.

113{
114 BIO_SANITIZE(m_size < std::numeric_limits< Index >::max(), ,
115 return)
116 Index targetSize = m_size * m_size; //squared.
117 if (targetSize < m_size)
118 {
119 targetSize = std::numeric_limits< Index >::max();
120 }
121 m_store = (unsigned char*)std::realloc(
122 m_store,
123 targetSize * GetStepSize());
125 return)
126 m_size = targetSize;
127}
virtual const std::size_t GetStepSize() const
Definition: Container.cpp:353

References BIO_SANITIZE, GetStepSize(), m_size, and m_store.

Referenced by GetNextAvailableIndex(), and Insert().

◆ GetAllocatedSize()

Index bio::Container::GetAllocatedSize ( ) const
virtual

GetCapacity - the number of free Indices at the end (ignores any deallocated Indices in the middle).

Returns
the number of Indices that have been allocated in *this.

Definition at line 79 of file Container.cpp.

80{
81 return m_firstFree;
82}

References m_firstFree.

Referenced by GetEndIndex(), GetNumberOfElements(), bio::Iterator::Increment(), Insert(), and bio::Iterator::IsAtEnd().

◆ GetBeginIndex()

Index bio::Container::GetBeginIndex ( ) const
virtual

◆ GetCapacity()

Index bio::Container::GetCapacity ( ) const
virtual
Returns
the number of allocatable Indices in *this.

Definition at line 74 of file Container.cpp.

75{
76 return m_size;
77}

References m_size.

Referenced by Insert().

◆ GetEndIndex()

Index bio::Container::GetEndIndex ( ) const
virtual
Returns
where to end.

Definition at line 69 of file Container.cpp.

70{
71 return GetAllocatedSize();
72}
virtual Index GetAllocatedSize() const
Definition: Container.cpp:79

References GetAllocatedSize().

Referenced by Clear(), End(), bio::chemical::LinearMotif< CONTENT_TYPE >::InsertImplementation(), SeekTo(), bio::physical::Line::SeekToId(), and bio::physical::Line::SeekToName().

◆ GetNextAvailableIndex()

Index bio::Container::GetNextAvailableIndex ( )
protectedvirtual

For ease of use when Add()ing. NOTE: This will mark the returned Index as filled, so please make sure it actually receives content.

Returns
a Index to fill with new content.

Definition at line 329 of file Container.cpp.

330{
331 Index ret = InvalidIndex();
332 if (!m_deallocated.empty())
333 {
334 ret = m_deallocated.front();
335 m_deallocated.pop_front();
336 }
337 else if (m_firstFree == m_size)
338 {
339 Expand();
340 ret = m_firstFree++;
341 }
342 return ret;
343}
virtual void Expand()
Definition: Container.cpp:112
const Index InvalidIndex()
Definition: Types.cpp:26

References Expand(), bio::InvalidIndex(), m_deallocated, m_firstFree, and m_size.

Referenced by Add(), and bio::physical::Arrangement< TYPE >::Add().

◆ GetNumberOfElements()

Index bio::Container::GetNumberOfElements ( ) const
virtual

GetAllocatedSize - the number of deallocated Indices.

Returns
the number of elements in *this.

Definition at line 84 of file Container.cpp.

85{
86 return GetAllocatedSize() - m_deallocated.size();
87}

References GetAllocatedSize(), and m_deallocated.

Referenced by bio::chemical::UnorderedMotif< CONTENT_TYPE >::GetCountImplementation(), and bio::chemical::UnorderedMotif< CONTENT_TYPE >::HasAllImplementation().

◆ GetStepSize()

const std::size_t bio::Container::GetStepSize ( ) const
protectedvirtual

Please override this to return the size of the type your Container interface is working with.

Returns
the size of the data type stored in *this.

Reimplemented in bio::physical::Arrangement< TYPE >, bio::physical::Arrangement< Linear >, and bio::physical::Arrangement< Bond * >.

Definition at line 353 of file Container.cpp.

354{
355 return sizeof(ByteStream);
356}

Referenced by Container(), Expand(), and Insert().

◆ Has()

bool bio::Container::Has ( const ByteStream  content) const
Parameters
content
Returns
whether or not *this contains the given content.

Definition at line 232 of file Container.cpp.

233{
234 return SeekTo(content); //implicit cast to bool should work.
235}
Index SeekTo(const ByteStream content) const
Definition: Container.cpp:209

References SeekTo().

Referenced by bio::chemical::LinearMotif< CONTENT_TYPE >::HasImplementation(), and bio::chemical::UnorderedMotif< CONTENT_TYPE >::HasImplementation().

◆ Import()

void bio::Container::Import ( const Container other)
virtual

Copy the contents of other into *this.

Parameters
other

Definition at line 251 of file Container.cpp.

252{
253 BIO_SANITIZE(other, ,
254 return)
255 Iterator* otr = other->End();
256 for (
257 ; !otr->IsAtBeginning();
258 --otr
259 )
260 {
261 Add(**otr);
262 }
263}
virtual Index Add(const ByteStream content)
Definition: Container.cpp:129

References Add(), BIO_SANITIZE, End(), and bio::Iterator::IsAtBeginning().

Referenced by Container(), bio::chemical::LinearMotif< CONTENT_TYPE >::LinearMotif(), bio::chemical::LinearMotif< CONTENT_TYPE >::ImportImplementation(), and bio::chemical::UnorderedMotif< CONTENT_TYPE >::ImportImplementation().

◆ Insert()

Index bio::Container::Insert ( const ByteStream  content,
const Index  index 
)
virtual

Adds content to *this at the specified position. All content past the given position is shifted down. NOTE: This explicitly breaks our rule about Indices being preserved. However, this logic is necessary if the items being inserted need to be accessed in the specified order; for example: the items in *this are molecular::Proteins that have a set execution order.

To make implementing your own Containers easier, this method simply hacks the GetNextAvailableIndex method to return the desired index and then calls Add. Thus, by implementing Add, you also implement Insert.

Parameters
content
Returns
the Index of the added content.

Definition at line 141 of file Container.cpp.

145{
146 BIO_SANITIZE(index, ,
147 return InvalidIndex())
148
149 if (index == m_firstFree)
150 {
151 //no adjustment necessary.
152 Add(content);
153 }
154
155 if (GetAllocatedSize() == GetCapacity())
156 {
157 Expand();
158 }
159
160 //move all memory down 1.
161 std::memcpy(
162 &m_store[index * GetStepSize()],
163 &m_store[(index + 1) * GetStepSize()],
164 (m_firstFree - index) * GetStepSize());
165
166 //adjust all deallocated positions.
167 std::deque< Index > adjustedDeallocations;
168 for (
169 std::deque< Index >::iterator dlc = m_deallocated.begin();
170 dlc != m_deallocated.end();
171 ++dlc
172 )
173 {
174 adjustedDeallocations.push_front(*dlc + 1);
175 }
176 m_deallocated = adjustedDeallocations;
177
178 //make sure we add to the desired index.
179 m_deallocated.push_front(index);
180
181 //add the content.
182 return Add(content);
183}
virtual Index GetCapacity() const
Definition: Container.cpp:74

References Add(), BIO_SANITIZE, Expand(), GetAllocatedSize(), GetCapacity(), GetStepSize(), bio::InvalidIndex(), m_deallocated, m_firstFree, and m_store.

Referenced by bio::chemical::LinearMotif< CONTENT_TYPE >::InsertImplementation().

◆ IsAllocated()

bool bio::Container::IsAllocated ( const Index  index) const
virtual

◆ IsFree()

bool bio::Container::IsFree ( const Index  index) const
virtual

Checks if the given Index is available to be allocated, i.e. the Index should not be used. NOTE: Just because a Index is not free does not necessarily mean the Index has been allocated.

Parameters
index
Returns
whether or not the given Index is free to use.

Definition at line 94 of file Container.cpp.

95{
96 if (index >= m_firstFree)
97 {
98 return true;
99 }
100 return std::find(
101 m_deallocated.begin(),
102 m_deallocated.end(),
103 index
104 ) != m_deallocated.end();
105}

References m_deallocated, and m_firstFree.

Referenced by bio::Iterator::Decrement(), bio::Iterator::Increment(), and IsAllocated().

◆ IsInRange()

bool bio::Container::IsInRange ( const Index  index) const
virtual

NOTE: Just because a Index IsInRange does not mean it is free or allocated.

Parameters
index
Returns
whether or not the Index is expected to yield a valid result when used with *this.

Definition at line 89 of file Container.cpp.

90{
91 return index && index < m_size;
92}

References m_size.

Referenced by IsAllocated().

◆ operator[]() [1/4]

ByteStream bio::Container::operator[] ( const Index  index)
virtual

Ease of use wrapper around Access. See Access for details.

Parameters
index
Returns
Access(Index).

Definition at line 309 of file Container.cpp.

310{
311 return Access(index);
312}

References Access().

◆ operator[]() [2/4]

const ByteStream bio::Container::operator[] ( const Index  index) const
virtual

Ease of use wrapper around Access. See Access for details.

Parameters
index
Returns
Access(Index).

Definition at line 314 of file Container.cpp.

315{
316 return Access(index);
317}

References Access().

◆ operator[]() [3/4]

ByteStream bio::Container::operator[] ( const SmartIterator  itt)
virtual

Ease of use wrapper around Access. See Access for details.

Parameters
itt
Returns
Access(itt).

Definition at line 319 of file Container.cpp.

320{
321 return Access(itt);
322}

References Access().

◆ operator[]() [4/4]

const ByteStream bio::Container::operator[] ( const SmartIterator  itt) const
virtual

Ease of use wrapper around Access. See Access for details.

Parameters
itt
Returns
Access(itt).

Definition at line 324 of file Container.cpp.

325{
326 return Access(itt);
327}

References Access().

◆ SeekTo()

Index bio::Container::SeekTo ( const ByteStream  content) const

Find the Index of content within *this.

Parameters
content
Returns
the Index of content within *this or InvalidIndex.

Definition at line 209 of file Container.cpp.

210{
211 if (!m_tempItt)
212 {
214 }
216 for (
218 --m_tempItt
219 )
220 {
221 if (AreEqual(
223 content
224 ))
225 {
226 return m_tempItt->GetIndex();
227 }
228 }
229 return InvalidIndex();
230}
virtual bool AreEqual(Index internal, const ByteStream external) const
Definition: Container.cpp:345

References AreEqual(), ConstructClassIterator(), GetEndIndex(), bio::Iterator::GetIndex(), bio::InvalidIndex(), bio::Iterator::IsAtBeginning(), m_tempItt, and bio::Iterator::MoveTo().

Referenced by Has(), and bio::chemical::UnorderedMotif< CONTENT_TYPE >::RemoveImplementation().

Member Data Documentation

◆ m_deallocated

std::deque< Index > bio::Container::m_deallocated
protected

◆ m_firstFree

Index bio::Container::m_firstFree
protected

Definition at line 343 of file Container.h.

Referenced by Clear(), GetAllocatedSize(), GetNextAvailableIndex(), Insert(), and IsFree().

◆ m_size

Index bio::Container::m_size
protected

Definition at line 342 of file Container.h.

Referenced by Container(), Expand(), GetCapacity(), GetNextAvailableIndex(), and IsInRange().

◆ m_store

unsigned char* bio::Container::m_store
protected

cannot be void* as we need an object type for pointer arithmetic.

Definition at line 340 of file Container.h.

Referenced by Container(), ~Container(), Access(), bio::physical::Arrangement< TYPE >::Access(), Add(), bio::physical::Arrangement< TYPE >::Add(), bio::physical::Arrangement< TYPE >::Erase(), Erase(), Expand(), and Insert().

◆ m_tempItt

Iterator* bio::Container::m_tempItt
mutableprotected

An iterator for use in loops. Matches lifecycle of object for better performance.

Definition at line 350 of file Container.h.

Referenced by ~Container(), Clear(), SeekTo(), bio::physical::Line::SeekToId(), and bio::physical::Line::SeekToName().


The documentation for this class was generated from the following files: