Jameo Core Library
Loading...
Searching...
No Matches
Classes | Public Member Functions | Protected Member Functions | List of all members
jm::Hashtable Class Reference

A hash table is an instrument used to sort data. A string serves as the access key, whose hash value ensures fast access. This class provides all the necessary methods to be able to work comfortably with a hash table. More...

Inheritance diagram for jm::Hashtable:
jm::Object jm::Preferences jm::I18nBundle

Public Member Functions

 Hashtable () noexcept
 Default constructor for the Hashtable class.
 
 ~Hashtable () noexcept override
 Destructor for the Hashtable class.
 
void * put (String key, void *value) noexcept
 This method inserts a new element into the hash table.
 
void * get (const String &key) const noexcept
 This method returns the object associated with the specified key.
 
void * remove (const String &key) noexcept
 This method removes the object associated with the specified key.
 
size_t size () const noexcept
 Returns the number of entries in this hash table.
 
bool isEmpty () const noexcept
 This method returns true if the hashtable is empty.
 
bool containsKey (const String &key) const noexcept
 This method returns true if an object is associated with the specified key.
 
bool containsValue (void *value) const noexcept
 This method returns true if the hashtable contains an object associated with the specified value.
 
Iteratorkeys () noexcept
 This method returns an object of the "Iterator" class that iterates through the keys of this table.
 
Iteratorvalues () noexcept
 This method returns an object of the "Iterator" class that iterates through the values of this table.
 
void clear () noexcept
 This method removes all elements from the Hashtable.
 
- Public Member Functions inherited from jm::Object
 Object () noexcept
 Constructor.
 
virtual ~Object () noexcept
 Destructor.
 
void release () noexcept
 Decreases the reference counter and releases the object immediately when the reference counter becomes 0.
 
Objectretain () noexcept
 Increases the reference counter of this object by 1.
 
Objectautorelease () noexcept
 Same function as release(), but releases the object with a delay if the reference counter is 0. AutoreleasePool::drain() must be called in the to release the object.
 
int32 referenceCount () const noexcept
 Returns the value of the reference counter.
 
virtual bool equals (const Object *other) const
 Comparison of objects.
 
virtual String displayName () const
 Returns the display name of the object intended to present to a user.
 
virtual void printDiffInfo (DiffOperation operation, Object *other) const
 Output method for outputting the diff results for the diff algorithm.
 
void setHighBit (bool status) noexcept
 
bool highBit () const noexcept
 

Protected Member Functions

void rehash () noexcept
 This method increases the capacity of the Hashtable.
 

Detailed Description

A hash table is an instrument used to sort data. A string serves as the access key, whose hash value ensures fast access. This class provides all the necessary methods to be able to work comfortably with a hash table.

Constructor & Destructor Documentation

◆ Hashtable()

jm::Hashtable::Hashtable ( )
noexcept

Default constructor for the Hashtable class.

◆ ~Hashtable()

jm::Hashtable::~Hashtable ( )
overridenoexcept

Destructor for the Hashtable class.

Member Function Documentation

◆ clear()

void jm::Hashtable::clear ( )
noexcept

This method removes all elements from the Hashtable.

◆ containsKey()

bool jm::Hashtable::containsKey ( const String key) const
noexcept

This method returns true if an object is associated with the specified key.

Parameters
keyThe key for which the object is being checked.
Returns
true if an object is associated with the key, false otherwise.

◆ containsValue()

bool jm::Hashtable::containsValue ( void *  value) const
noexcept

This method returns true if the hashtable contains an object associated with the specified value.

Parameters
valueThe value to search for.
Returns
true if an object is associated with the value, false otherwise.

◆ get()

void * jm::Hashtable::get ( const String key) const
noexcept

This method returns the object associated with the specified key.

Parameters
keyThe key to which the object is associated.
Returns
A pointer to the object associated with the key, or nullptr if the object is not present in the hashtable.

◆ isEmpty()

bool jm::Hashtable::isEmpty ( ) const
noexcept

This method returns true if the hashtable is empty.

Returns
true if the hashtable is empty, false otherwise.

◆ keys()

Iterator * jm::Hashtable::keys ( )
noexcept

This method returns an object of the "Iterator" class that iterates through the keys of this table.

Returns
An Iterator object that iterates through the keys of this table.

◆ put()

void * jm::Hashtable::put ( String  key,
void *  value 
)
noexcept

This method inserts a new element into the hash table.

Parameters
keyThe key to which the object will be associated.
valueThe pointer to the object to be inserted.
Returns
If an old object is replaced, it is returned.

◆ rehash()

void jm::Hashtable::rehash ( )
protectednoexcept

This method increases the capacity of the Hashtable.

◆ remove()

void * jm::Hashtable::remove ( const String key)
noexcept

This method removes the object associated with the specified key.

Parameters
keyThe key to which the object is associated.
Returns
A pointer to the object that was removed, or nullptr if the object was not found.

◆ size()

size_t jm::Hashtable::size ( ) const
noexcept

Returns the number of entries in this hash table.

◆ values()

Iterator * jm::Hashtable::values ( )
noexcept

This method returns an object of the "Iterator" class that iterates through the values of this table.

Returns
An Iterator object that iterates through the values of this table.