System CATHashTable
Usage: you must use this class as is. You should never derive it.
public class CATHashTable
Class to define a hash table.
Role:The class collection you will obtain will gain benefits of C++
strong type checking, but its designed to reduce executable code size and
to fasten heavily used operations. This table is not ordered, contains
no duplicate elements and no null elements.
It is up to you to provide the dimension, the hash-code function and the
compare function for each instance of hash table. Only the underlying
infrastructure is offered.
Constructor and Destructor Index
- o
CATHashTable(CATHashTable&)
- Constructs a new hash table from an another one.
- o
CATHashTable(CATCollec::PFHash,CATCollec::PFCompare,int)
- Constructs an empty hash table.
- o
~CATHashTable()
-
Method Index
- o
Collisions()
- Returns the count of item not directly accessible in a hash table.
- o
Dimension()
- Returns the number of bucket in the hash table.
- o
Insert(void*)
- Inserts an item in the hash table.
- o
KeyLocate(CATHashKey)
- Returns the item with has a given hash value key.
- o
KeyLocatePosition(CATHashKey,int&,int&)
- Returns the item with has a given hash value key.
- o
Locate(void*)
- Returns an item from a key corresponding to an another item.
- o
LocatePosition(void*,int&,int&)
- Returns an item from a key corresponding to an another item.
- o
Next(void*)
- Returns the next item given a key in a hash table.
- o
Next(int&,int&)
- Returns the next item given a position in a hash table.
- o
Remove(void*)
- Removes an item in the hash table.
- o
RemoveAll()
- Removes all elements in the hash table.
- o
RemovePosition(int,int)
- Removes an item in the hash table.
- o
Retrieve(int,int)
- Retrieves an item from its Bucket and Position in a hash table.
- o
Size()
- Returns the count of item in the hash table.
- o
Unused()
- Returns the count of unused buckets in an hash table.
Constructor and Destructor
o CATHashTable
public CATHashTable( | const | iCopy) |
-
Constructs a new hash table from an another one.
Role: This new table as same characteristics and
contents is copied.
- Parameters:
-
- iCopy
- The hash table to duplicate
o CATHashTable
public CATHashTable( | | iPFH, |
| | iPFC, |
| | iDimension | = 10 ) |
-
Constructs an empty hash table.
Role:Constructs an empty hash table of dimension iDimension.
The hash table contains X buckets, X is defined from iDimension. An item
is inserted in a bucked according to its key hash value. A bucket can contain
several items with not the same key.
- Parameters:
-
- iPFH
- Pointeur on a global hashing function. This function must returned a
key of each element of the table.
- iPFC
- Pointeur on a global comparison function. This function must return 0
if both instance of the table are equal.
- iDimension
- Helps specifying the number of bucket (cells receiving 0 to N items) and
this number will not vary up to the destruction of the hash table.
Default value:10
o ~CATHashTable
-
Methods
o Collisions
-
Returns the count of item not directly accessible in a hash table.
Role: Item directly accessible are those at the first position
in a bucket.
o Dimension
-
Returns the number of bucket in the hash table.
Role:This number is also the maximum number of items without
collisions.
o Insert
-
Inserts an item in the hash table.
Role:Inserts an item according to its key in the table. The key
is computed with the provided hash-code function with iAdd as argument.
- Parameters:
-
- iAdd
- Item to insert
- Returns:
- If the key already exists, nothing is inserted and 0 is returned else iAdd is
inserted in a bucket and 1 is returned.
o KeyLocate
-
Returns the item with has a given hash value key.
- Parameters:
-
- iKey
- Hash value key.
- Returns:
- The item which has iKey hash table key value, or NULL if not found.
o KeyLocatePosition
public KeyLocatePosition( | | iKey, |
| | oBucket, |
| | oPosition) |
-
Returns the item with has a given hash value key.
- Parameters:
-
- iKey
- Hash value key.
- oBucket
- the bucket of the item
- oPosition
- The position of this item in the bucket.
- Returns:
- The item which has iKey hash table key value, or NULL if not found.
o Locate
-
Returns an item from a key corresponding to an another item.
- Parameters:
-
- iLocate
- We used it's key .
- Returns:
- The item having a key corresponding to iLocate key's or NULL if not found.
o LocatePosition
public LocatePosition( | | iLocate, |
| | oBucket, |
| | oPosition) |
-
Returns an item from a key corresponding to an another item.
- Parameters:
-
- iLocate
- The element to find in the table.
- oBucket
- The bucket of the returned item
- oPosition
- The position in the bucket of the returned item
- Returns:
- The item having a key corresponding to iLocate key's or NULL if not found.
o Next
-
Returns the next item given a key in a hash table.
Role:Iterator of the hash table. To start a loop on all items set
iFrom to NULL. If the returned value is NULL, you have reached
the end of the table.
- Parameters:
-
- iFrom
- The returned value is the next item of iFrom
- Returns:
- The next item after iFrom
o Next
public Next( | | ioBucket, |
| | ioPosition) |
-
Returns the next item given a position in a hash table.
Role:Iterator of the hash table. To start a loop on all items set
ioBucket to 1 and ioPosition to 0. If the returned value is NULL, you have reached
the end of the table.
- Parameters:
-
- ioBucket
- The bucket used to find the next item
- ioPosition
- The position in the ioBucket used to find the next item
- Returns:
- The next item next to the given position (iBucket, iPosition).
o Remove
-
Removes an item in the hash table.
- Parameters:
-
- iRemove
- The element to remove
- Returns:
- The element removed or NULL if not exists
o RemoveAll
-
Removes all elements in the hash table.
o RemovePosition
public RemovePosition( | | iBucket, |
| | iPosition) |
-
Removes an item in the hash table.
- Returns:
- The element removed or NULL if not exists
o Retrieve
public Retrieve( | | iBucket, |
| | iPosition) |
-
Retrieves an item from its Bucket and Position in a hash table.
- Parameters:
-
- iBucket
- The bucket of the returned item
- iPosition
- The position in the bucket of the returned item
- Returns:
- Returns the item having position descibed by the couple of integer (iBucket,iPosition)
o Size
-
Returns the count of item in the hash table..
o Unused
-
Returns the count of unused buckets in an hash table.
This object is included in the file: CATHashTable.h
If needed, your Imakefile.mk should include the module: JS0GROUP
Copyright © 1999-2015, Dassault Systèmes. All rights reserved.