Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
IceCore::Container Class Reference

#include <OPC_IceHook.h>

Inheritance diagram for IceCore::Container:
Inheritance graph
[legend]

Public Member Functions

inline_ ContainerAdd (udword entry)
 
inline_ ContainerAdd (const udword *entries, udword nb)
 
inline_ ContainerAdd (float entry)
 
inline_ ContainerAdd (const float *entries, udword nb)
 
inline_ ContainerAddUnique (udword entry)
 Add unique [slow]. More...
 
 Container ()
 
 Container (const Container &object)
 
 Container (udword size, float growth_factor)
 
bool Contains (udword entry, udword *location=null) const
 
bool Delete (udword entry)
 
inline_ void DeleteIndex (udword index)
 Deletes the entry whose index is given. More...
 
bool DeleteKeepingOrder (udword entry)
 
inline_ void DeleteLastEntry ()
 Deletes the very last entry. More...
 
ContainerEmpty ()
 
ContainerFindNext (udword &entry, FindMode find_mode=FIND_CLAMP)
 
ContainerFindPrev (udword &entry, FindMode find_mode=FIND_CLAMP)
 
inline_ void ForceSize (udword size)
 
inline_ udwordGetEntries () const
 Returns the list of entries. More...
 
inline_ udword GetEntry (udword i) const
 Returns ith entry. More...
 
inline_ udword GetFirst () const
 
inline_ float GetGrowthFactor () const
 Returns the growth factor. More...
 
inline_ udword GetLast () const
 
inline_ udword GetNbContainers () const
 Operator for "Container A = Container B". More...
 
inline_ udword GetNbEntries () const
 Returns the current number of entries. More...
 
inline_ udword GetTotalBytes () const
 
udword GetUsedRam () const
 
inline_ bool IsFull () const
 Checks the container is full. More...
 
inline_ BOOL IsNotEmpty () const
 Checks the container is empty. More...
 
inline_ udword operator[] (udword i) const
 Read-access as an array. More...
 
inline_ udwordoperator[] (udword i)
 Write-access as an array. More...
 
bool Refit ()
 
inline_ void Reset ()
 
inline_ void SetGrowthFactor (float growth)
 Sets the growth factor. More...
 
bool SetSize (udword nb)
 
 ~Container ()
 

Private Member Functions

bool Resize (udword needed=1)
 

Private Attributes

udword mCurNbEntries
 Current number of entries. More...
 
udwordmEntries
 List of entries. More...
 
float mGrowthFactor
 Resize: new number of entries = old number * mGrowthFactor. More...
 
udword mMaxNbEntries
 Maximum possible number of entries. More...
 

Static Private Attributes

static udword mNbContainers
 Number of containers around. More...
 
static udword mUsedRam
 Amount of bytes used by containers in the system. More...
 

Detailed Description

Definition at line 26 of file OPC_IceHook.h.

Constructor & Destructor Documentation

◆ Container() [1/3]

Container::Container ( )

Constructor. No entries allocated there.

Definition at line 40 of file IceContainer.cpp.

◆ Container() [2/3]

Container::Container ( const Container object)

Copy constructor.

Definition at line 67 of file IceContainer.cpp.

◆ Container() [3/3]

Container::Container ( udword  size,
float  growth_factor 
)

Constructor. Also allocates a given number of entries.

Definition at line 53 of file IceContainer.cpp.

◆ ~Container()

Container::~Container ( )

Destructor. Frees everything and leaves.

Definition at line 81 of file IceContainer.cpp.

Member Function Documentation

◆ Add() [1/4]

inline_ Container& IceCore::Container::Add ( udword  entry)
inline

A O(1) method to add a value in the container. The container is automatically resized if needed. The method is inline, not the resize. The call overhead happens on resizes only, which is not a problem since the resizing operation costs a lot more than the call overhead...

Parameters
entry[in] a udword to store in the container
See also
Add(float entry)
Empty()
Contains(udword entry)
Returns
Self-Reference

Definition at line 48 of file OPC_IceHook.h.

◆ Add() [2/4]

inline_ Container& IceCore::Container::Add ( const udword entries,
udword  nb 
)
inline

Definition at line 58 of file OPC_IceHook.h.

◆ Add() [3/4]

inline_ Container& IceCore::Container::Add ( float  entry)
inline

A O(1) method to add a value in the container. The container is automatically resized if needed. The method is inline, not the resize. The call overhead happens on resizes only, which is not a problem since the resizing operation costs a lot more than the call overhead...

Parameters
entry[in] a float to store in the container
See also
Add(udword entry)
Empty()
Contains(udword entry)
Returns
Self-Reference

Definition at line 82 of file OPC_IceHook.h.

◆ Add() [4/4]

inline_ Container& IceCore::Container::Add ( const float *  entries,
udword  nb 
)
inline

Definition at line 92 of file OPC_IceHook.h.

◆ AddUnique()

inline_ Container& IceCore::Container::AddUnique ( udword  entry)
inline

Add unique [slow].

Definition at line 104 of file OPC_IceHook.h.

◆ Contains()

bool Container::Contains ( udword  entry,
udword location = null 
) const

Checks whether the container already contains a given value.

Parameters
entry[in] the value to look for in the container
location[out] a possible pointer to store the entry location
See also
Add(udword entry)
Add(float entry)
Empty()
Returns
true if the value has been found in the container, else false.

Definition at line 224 of file IceContainer.cpp.

◆ Delete()

bool Container::Delete ( udword  entry)

Deletes an entry. If the container contains such an entry, it's removed.

Parameters
entry[in] the value to delete.
Returns
true if the value has been found in the container, else false.
Warning
This method is arbitrary slow (O(n)) and should be used carefully. Insertion order is not preserved.

Definition at line 246 of file IceContainer.cpp.

◆ DeleteIndex()

inline_ void IceCore::Container::DeleteIndex ( udword  index)
inline

Deletes the entry whose index is given.

Definition at line 165 of file OPC_IceHook.h.

◆ DeleteKeepingOrder()

bool Container::DeleteKeepingOrder ( udword  entry)

Deletes an entry, preserving the insertion order. If the container contains such an entry, it's removed.

Parameters
entry[in] the value to delete.
Returns
true if the value has been found in the container, else false.
Warning
This method is arbitrary slow (O(n)) and should be used carefully.

Definition at line 269 of file IceContainer.cpp.

◆ DeleteLastEntry()

inline_ void IceCore::Container::DeleteLastEntry ( )
inline

Deletes the very last entry.

Definition at line 163 of file OPC_IceHook.h.

◆ Empty()

Container & Container::Empty ( )

Clears the container. All stored values are deleted, and it frees used ram.

See also
Reset()
Returns
Self-Reference

Definition at line 97 of file IceContainer.cpp.

◆ FindNext()

Container & Container::FindNext ( udword entry,
FindMode  find_mode = FIND_CLAMP 
)

Gets the next entry, starting from input one.

Parameters
entry[in/out] On input, the entry to look for. On output, the next entry
find_mode[in] wrap/clamp
Returns
Self-Reference

Definition at line 297 of file IceContainer.cpp.

◆ FindPrev()

Container & Container::FindPrev ( udword entry,
FindMode  find_mode = FIND_CLAMP 
)

Gets the previous entry, starting from input one.

Parameters
entry[in/out] On input, the entry to look for. On output, the previous entry
find_mode[in] wrap/clamp
Returns
Self-Reference

Definition at line 317 of file IceContainer.cpp.

◆ ForceSize()

inline_ void IceCore::Container::ForceSize ( udword  size)
inline

Definition at line 134 of file OPC_IceHook.h.

◆ GetEntries()

inline_ udword* IceCore::Container::GetEntries ( ) const
inline

Returns the list of entries.

Definition at line 173 of file OPC_IceHook.h.

◆ GetEntry()

inline_ udword IceCore::Container::GetEntry ( udword  i) const
inline

Returns ith entry.

Definition at line 172 of file OPC_IceHook.h.

◆ GetFirst()

inline_ udword IceCore::Container::GetFirst ( ) const
inline

Definition at line 175 of file OPC_IceHook.h.

◆ GetGrowthFactor()

inline_ float IceCore::Container::GetGrowthFactor ( ) const
inline

Returns the growth factor.

Definition at line 179 of file OPC_IceHook.h.

◆ GetLast()

inline_ udword IceCore::Container::GetLast ( ) const
inline

Definition at line 176 of file OPC_IceHook.h.

◆ GetNbContainers()

inline_ udword IceCore::Container::GetNbContainers ( ) const
inline

Operator for "Container A = Container B".

Definition at line 196 of file OPC_IceHook.h.

◆ GetNbEntries()

inline_ udword IceCore::Container::GetNbEntries ( ) const
inline

Returns the current number of entries.

Definition at line 171 of file OPC_IceHook.h.

◆ GetTotalBytes()

inline_ udword IceCore::Container::GetTotalBytes ( ) const
inline

Definition at line 197 of file OPC_IceHook.h.

◆ GetUsedRam()

udword Container::GetUsedRam ( ) const

Gets the ram used by the container.

Returns
the ram used in bytes.

Definition at line 335 of file IceContainer.cpp.

◆ IsFull()

inline_ bool IceCore::Container::IsFull ( ) const
inline

Checks the container is full.

Definition at line 181 of file OPC_IceHook.h.

◆ IsNotEmpty()

inline_ BOOL IceCore::Container::IsNotEmpty ( ) const
inline

Checks the container is empty.

Definition at line 182 of file OPC_IceHook.h.

◆ operator[]() [1/2]

inline_ udword IceCore::Container::operator[] ( udword  i) const
inline

Read-access as an array.

Definition at line 185 of file OPC_IceHook.h.

◆ operator[]() [2/2]

inline_ udword& IceCore::Container::operator[] ( udword  i)
inline

Write-access as an array.

Definition at line 187 of file OPC_IceHook.h.

◆ Refit()

bool Container::Refit ( )

Refits the container and get rid of unused bytes.

Returns
true if success

Definition at line 181 of file IceContainer.cpp.

◆ Reset()

inline_ void IceCore::Container::Reset ( )
inline

Resets the container. Stored values are discarded but the buffer is kept so that further calls don't need resizing again. That's a kind of temporal coherence.

See also
Empty()

Definition at line 126 of file OPC_IceHook.h.

◆ Resize()

bool Container::Resize ( udword  needed = 1)
private

Resizes the container.

Parameters
needed[in] assume the container can be added at least "needed" values
Returns
true if success.

Definition at line 114 of file IceContainer.cpp.

◆ SetGrowthFactor()

inline_ void IceCore::Container::SetGrowthFactor ( float  growth)
inline

Sets the growth factor.

Definition at line 180 of file OPC_IceHook.h.

◆ SetSize()

bool Container::SetSize ( udword  nb)

Sets the initial size of the container. If it already contains something, it's discarded.

Parameters
nb[in] Number of entries
Returns
true if success

Definition at line 153 of file IceContainer.cpp.

Member Data Documentation

◆ mCurNbEntries

udword IceCore::Container::mCurNbEntries
private

Current number of entries.

Definition at line 208 of file OPC_IceHook.h.

◆ mEntries

udword* IceCore::Container::mEntries
private

List of entries.

Definition at line 209 of file OPC_IceHook.h.

◆ mGrowthFactor

float IceCore::Container::mGrowthFactor
private

Resize: new number of entries = old number * mGrowthFactor.

Definition at line 210 of file OPC_IceHook.h.

◆ mMaxNbEntries

udword IceCore::Container::mMaxNbEntries
private

Maximum possible number of entries.

Definition at line 207 of file OPC_IceHook.h.

◆ mNbContainers

udword IceCore::Container::mNbContainers
staticprivate

Number of containers around.

Definition at line 200 of file OPC_IceHook.h.

◆ mUsedRam

udword IceCore::Container::mUsedRam
staticprivate

Amount of bytes used by containers in the system.

Definition at line 201 of file OPC_IceHook.h.


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


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Thu Sep 8 2022 02:24:09