Container Class Reference

Inherited by CollisionFaces [private], MatrixPalette, Opcode::CollisionFaces [private], and Vertices.

List of all members.

Public Methods

 Container ()
 Container (udword size, float growthfactor)
 ~Container ()
__forceinline Container & Add (udword entry)
__forceinline Container & Add (float entry)
Container & AddUnique (udword entry)
 Add unique [slow].

__forceinline Container & Empty ()
__forceinline void Reset ()
bool SetSize (udword nb)
bool Refit ()
bool Contains (udword entry, udword *location=null) const
bool Delete (udword entry)
bool DeleteKeepingOrder (udword entry)
__forceinline void DeleteLastEntry ()
 A method to delete the very last entry.

__forceinline void DeleteIndex (udword index)
 A method to delete the entry whose index is given.

Container & FindNext (udword &entry, bool wrap=false)
Container & FindPrev (udword &entry, bool wrap=false)
__forceinline udword GetNbEntries () const
 Returns the current number of entries.

__forceinline udword GetEntry (udword i) const
 Returns ith entry.

__forceinline udwordGetEntries () const
 Returns the list of entries.

__forceinline float GetGrowthFactor () const
 Returns the growth factor.

__forceinline void SetGrowthFactor (float growth)
 Sets the growth factor.

__forceinline udwordoperator[] (udword i) const
 Access as an array.

udword GetUsedRam () const
void operator= (const Container &object)
 Operator for Container A = Container B.


Detailed Description

Contains a list of 32-bits values. Use this class when you need to store an unknown number of values. The list is automatically resized and can contains 32-bits entities (dwords or floats)

Author:
Pierre Terdiman
Version:
1.0
Date:
08.15.98


Constructor & Destructor Documentation

Container::Container  
 

Constructor. No entries allocated there.

Container::Container udword    size,
float    growthfactor
 

Constructor. Also allocates a given number of entries.

Container::~Container  
 

Destructor. Frees everything and leaves.


Member Function Documentation

__forceinline Container& 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

__forceinline Container& 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

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

A method to check 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.

bool Container::Delete udword    entry
 

A method to delete 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.

bool Container::DeleteKeepingOrder udword    entry
 

A method to delete 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.

__forceinline Container& Container::Empty   [inline]
 

A method to clear the container. All stored values are deleted, and it frees used ram.

See also:
Reset()
Returns:
Self-Reference

Container & Container::FindNext udword   entry,
bool    wrap = false
 

A method to get the next entry, starting from input one.

Parameters:
entry  [in/out] On input, the entry to look for. On output, the next entry
wrap  [in] true to wrap at the end of the array
Returns:
Self-Reference

Container & Container::FindPrev udword   entry,
bool    wrap = false
 

A method to get the previous entry, starting from input one.

Parameters:
entry  [in/out] On input, the entry to look for. On output, the previous entry
wrap  [in] true to wrap at the end of the array
Returns:
Self-Reference

udword Container::GetUsedRam   const
 

A method to get the ram used by the container.

Returns:
the ram used in bytes.

bool Container::Refit  
 

A method to refit the container and get rid of unused bytes.

Returns:
true if success

__forceinline void Container::Reset   [inline]
 

A method to reset 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()

bool Container::SetSize udword    nb
 

A method to set the initial size of the container. If it already contains something, it's discarded.

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


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


Flat Four Engine
Copyright (C) 2001 by 379, Inc.
This page generated by Doxygen