PrevNextUpHome SophiaFramework UNIVERSE 5.3
SFXLinkedHashMap
Class which represents a map utilizing a hash table and a list, to achieve high performance in search and to keep inserted order.
#include <SFXLinkedHashMap.h.hpp>
class SFXLinkedHashMap;
SFMTYPEDEFCLASS(SFXLinkedHashMap)

Inheritance diagram

 Inheritance diagram of SFXLinkedHashMapClass

Collaboration diagram

 Collaboration diagram of SFXLinkedHashMapClass

Description

SFXLinkedHashMap is a hashmap class which preserve the insertion order.

This class replaces the current SFXOldHashmap class whose name was "SFXHashmap" in SophiaFramework UNIVERSE 5.1.8 or below. The performance of rehashing, merging, and comparing is dramatically improved for large number of the elements.

Each key element of the SFXLinkedHashMap instance(hashmap) needs to be data not more than 4 byte, the SFXAnsiString instance, or the SFXWideString instance. In order to process data more than 4 byte(such as UInt64 type, Float64 type, and so on) or class instance as a value element of the SFXLinkedHashMap instance(hashmap), a pointer should be used.

When element occupancy rate for a hash table exceeds DEFAULT_THRESHOLD (45) %, the size of the hash table will be automatically expanded.

// data more than 4 byte or class instance cannot be a value element of the SFXLinkedHashMap instance ( hashmap )
// SFXLinkedHashMap<SFXAnsiString, SInt64> map64;          NG
// SFXLinkedHashMap<SFXAnsiString, SFXAnsiString> mapstr;  NG

// but a pointer to the data more than 4 byte or class instance can be a value element of the SFXLinkedHashMap instance ( hashmap )
SFXLinkedHashMap<SFXAnsiString, SInt64Ptr> map64;             // OK
SFXLinkedHashMap<<SFXAnsiString, SFXAnsiStringPtr> mapstr; // OK

Reference

SFXHashmap | SFXFlatHashMap | SFXAnsiString | SFXWideString | Hashmap

Member

Constructor/Destructor
SFXLinkedHashMap( Void )
Constructor of the SFXLinkedHashMap class.
SFXLinkedHashMap( UInt16 threshold , UInt16 ratio )
Constructor of the SFXLinkedHashMap class.
Public Functions
Void Clear( Void )
Clear this hashmap.
Bool ContainsKey( KeyType key )
Check whether or not this hashmap contains the specified key as the key of the pair element.
Bool ContainsValue( ValueType value )
Check whether or not this hashmap contains the specified value as the value of the pair element.
static
SFXLinkedHashMap< K, V > const &
EmptyInstance( Void )
Get the empty hashmap.
Bool Equals( SFXLinkedHashMap< K, V > const & collection )
Check whether or not this hashmap equals the specified hashmap.
ValueType Get( KeyType key , BoolPtr found = null )
Get the value of the key-value pair with the specified key from this hashmap.
KeyEnumerator GetFirstKeyEnumerator( Void )
Get the key enumerator that points to the key of the first pair element.
KeyIterator GetFirstKeyIterator( Void )
Get the key iterator that points to the key of the first pair element.
ValueEnumerator GetFirstValueEnumerator( Void )
Get the value enumerator that points to the value of the first pair element.
ValueIterator GetFirstValueIterator( Void )
Get the value iterator that points to the value of the first pair element.
KeyEnumerator GetKeyEnumerator( SInt32 index )
Get the key enumerator that points to the key of the pair element at the specified index.
KeyEnumerator GetKeyEnumerator( Void )
Get the key enumerator that points to the key of the pair element at the specified index.
KeyIterator GetKeyIterator( SInt32 index )
Get the key iterator that points to the key of the pair element at the specified index.
KeyIterator GetKeyIterator( Void )
Get the key iterator that points to the key of the pair element at the specified index.
KeyEnumerator GetLastKeyEnumerator( Void )
Get the key enumerator that points to the key of the last pair element.
KeyIterator GetLastKeyIterator( Void )
Get the key iterator that points to the key of the last pair element.
ValueEnumerator GetLastValueEnumerator( Void )
Get the value enumerator that points to the value of the last pair element.
ValueIterator GetLastValueIterator( Void )
Get the value iterator that points to the value of the last pair element.
UInt16 GetRatio( Void )
[DEPRECATED] Get the expansion ratio of hash table size.
SInt32 GetSize( Void )
Get the size of this hashmap.
UInt16 GetThreshold( Void )
[DEPRECATED] Get the threshold to expand the hash table size.
ValueEnumerator GetValueEnumerator( SInt32 index )
Get the value enumerator that points to the value of the pair element at the specified index.
ValueEnumerator GetValueEnumerator( Void )
Get the value enumerator that points to the value of the pair element at the specified index.
ValueIterator GetValueIterator( SInt32 index )
Get the value iterator that points to the value of the pair element at the specified index.
ValueIterator GetValueIterator( Void )
Get the value iterator that points to the value of the pair element at the specified index.
Bool IsEmpty( Void )
Check whether or not this hashmap is empty.
SFCError Merge( SFXLinkedHashMap< K, V > const & collection )
Merge this hashmap with the specified hashmap.
Void Remove( KeyType key )
Remove the key-value pair with the specified key from this hashmap.
SFCError Set( SFXLinkedHashMap< K, V > const & collection )
Set the specified key-value pair or hashmap into this hashmap.
SFCError Set( KeyType key , ValueType value )
Set the specified key-value pair or hashmap into this hashmap.
Void SetRatio( UInt16 ratio )
[DEPRECATED] Set the expansion ratio of hash table size.
Void SetThreshold( UInt16 threshold )
[DEPRECATED] Set the threshold to expand the hash table size.
SFCError Swap( KeyType destination , KeyType source )
Swap the value of two pair elements with the specified keys.
ValueType operator[]( KeyType key )
Get the value of the key-value pair with the specified key index from this hashmap.
Types
DefaultEnum
[DEPRECATED] Default threshold to expand the hash table.
KeyEnumerator
Class for managing the key enumerator for the keys of the pair elements of this hashmap.
KeyIterator
Class for managing the key iterator for the keys of the pair elements of this hashmap.
ValueEnumerator
Class for managing the value enumerator for the values of the pair elements of this hashmap.
ValueIterator
Class for managing the value iterator for the values of the pair elements of this hashmap.

SFXLinkedHashMap::SFXLinkedHashMap
Constructor of the SFXLinkedHashMap class.
[ public, explicit ]
SFXLinkedHashMap(Void);
[ public, explicit ]
SFXLinkedHashMap(
    UInt16 threshold   // unused
    UInt16 ratio       // unused
);

Description

Default implementation does nothing.

The arguments of this constructor are only for preserving the compatibility with the SFXOldHashmap class and will not be used inside this SFXLinkedHashMap class.

Reference

SFXOldHashmap


SFXLinkedHashMap::Clear
Clear this hashmap.
[ public ]
Void Clear(Void);

Description

This function clears this hashmap. All the internal buffer allocated to this hashmap will be released.

After this function is executed, the size of this hashmap will become 0.

If the key is a string(SFXAnsiString / SFXWideString), the string itself will be released automatically.

[Caution] Caution

If the type of the key or the value of the pair element is a pointer to a class instance or data bigger than 4 bytes, memory area that the pointer points to will not be released automatically.

Before clearing this hashmap, it is necessary to release that area explicitly using the delete statement. Otherwise, memory leakage will occur.

[Note] Note
This function will be called automatically when this hashmap goes out of scope.

Example

SFXLinkedHashMap<SFXAnsiString, SInt32> strmap;
 
...

strmap.Clear();   // clear the hashmap

Reference

SFXLinkedHashMap::Remove | SFXLinkedHashMap::GetSize


SFXLinkedHashMap::ContainsKey
Check whether or not this hashmap contains the specified key as the key of the pair element.
[ public, const ]
Bool ContainsKey(
    KeyType key   // key to check
);

Return value

  • If the specified key is contained: true
  • Otherwise: false

Description

This function checks whether or not this hashmap contains the specified key as the key of the pair element.

[Note] Note
If the type of the element is a pointer to a class instance or data bigger than 4 bytes, their addresses will be compared with.

Example

SFXLinkedHashMap<SFXAnsiString, SInt32> strmap;

// set a key-value pair element of (key: "mike", value: 2) into the hashmap
if (strmap.Set("mike", 2) == SFERR_NO_ERROR) {

    // set a key-value pair element of (key: "john", value: 1) into the hashmap
    if (strmap.Set("john", 1) == SFERR_NO_ERROR) {
    
        // check whether or not the hashmap contains the keys below
        TRACE("ContainsKey(\"mike\") = %s", (strmap.ContainsKey("mike")) ? ("true") : ("false"));  // containsKey("mike") = true
        TRACE("ContainsKey(\"tom\") = %s", (strmap.ContainsKey("tom")) ? ("true") : ("false"));    // containsKey("tom") = false
    }
}

Reference

SFXLinkedHashMap::ContainsValue


SFXLinkedHashMap::ContainsValue
Check whether or not this hashmap contains the specified value as the value of the pair element.
[ public, const ]
Bool ContainsValue(
    ValueType value   // value to check
);

Return value

  • If the specified value is contained: true
  • Otherwise: false

Description

This function checks whether or not this hashmap contains the specified value as the value of the pair element.

[Note] Note
If the type of the element is a pointer to a class instance or data bigger than 4 bytes, their addresses will be compared with.

Example

SFXLinkedHashMap<SFXAnsiString, SInt32> strmap;

// set a key-value pair element of (key: "mike", value: 2) into the hashmap
if (strmap.Set("mike", 2) == SFERR_NO_ERROR) {

    // set a key-value pair element of (key: "john", value: 1) into the hashmap
    if (strmap.Set("john", 1) == SFERR_NO_ERROR) {
    
        // check whether or not the hashmap contains the values below
        TRACE("ContainsValue(2) = %s", (strmap.ContainsValue(2)) ? ("true") : ("false"));  // containsValue(2) = true
        TRACE("ContainsValue(5) = %s", (strmap.ContainsValue(5)) ? ("true") : ("false"));  // containsValue(5) = false
    }
}

Reference

SFXLinkedHashMap::ContainsKey


SFXLinkedHashMap::EmptyInstance
Get the empty hashmap.
[ public, static ]
SFXLinkedHashMap< K, V > const & EmptyInstance(Void);

Return value

Empty hashmap

Description

This function gets the empty hashmap.

Reference

SFXLinkedHashMap::IsEmpty


SFXLinkedHashMap::Equals
Check whether or not this hashmap equals the specified hashmap.
[ public, const ]
Bool Equals(
    SFXLinkedHashMap< K, V > const & collection   // hashmap to compare with
);

Return value

  • If yes: true
  • Otherwise: false

Description

This function checks whether or not this hashmap equals the specified hashmap.

[Note] Note
If the type of the element is a pointer, its address will be compared with.

SFXLinkedHashMap::Get
Get the value of the key-value pair with the specified key from this hashmap.
[ public, const ]
ValueType Get(
    KeyType key            // key to get the value element
    BoolPtr found = null   // whether the key exists (optional)
);

Return value

If there is the key-value pair with the specified key in this hashmap, the corresponding value will be returned.

Otherwise, null or 0 will be returned.

Description

This function gets the value of the key-value pair with the specified key from this hashmap.

When a key-value pair with the specified key exists, the second parameter "found" is set to true. Otherwise, false.

[Caution] Caution
In case no key-value pair with the specified key exists, no error will occur but this function will return 0 or null.

Example

SFXLinkedHashMap<SFXAnsiString, SInt32> strmap;

// set a key-value pair element of (key: "mike", value: 2) into the hashmap
if (strmap.Set("mike", 2) == SFERR_NO_ERROR) {

    // set a key-value pair element of (key: "john", value: 1) into the hashmap
    if (strmap.Set("john", 1) == SFERR_NO_ERROR) {
    
        // display the value of the key-value pair with the specified key in BREW Output Window
        TRACE("%d", strmap.Get("mike"));  // 2
    }
}

Reference

SFXLinkedHashMap::operator[] | SFXLinkedHashMap::Set


SFXLinkedHashMap::GetFirstKeyEnumerator
Get the key enumerator that points to the key of the first pair element.
[ public, const ]
KeyEnumerator GetFirstKeyEnumerator(Void);

Return value

Key enumerator that points to the key of the first pair element

Description

This function gets the key enumerator of this hashmap that points to the key of the first pair element.

Reference

SFXLinkedHashMap::GetFirstKeyIterator | SFXLinkedHashMap::GetFirstValueIterator | SFXLinkedHashMap::GetFirstValueEnumerator | SFXLinkedHashMap::ValueEnumerator | SFXLinkedHashMap::ValueIterator | SFXLinkedHashMap::KeyEnumerator | SFXLinkedHashMap::KeyIterator


SFXLinkedHashMap::GetFirstKeyIterator
Get the key iterator that points to the key of the first pair element.
[ public ]
KeyIterator GetFirstKeyIterator(Void);

Return value

Key iterator that points to the key of the first pair element

Description

This function gets the key iterator of this hashmap that points to the key of the first pair element.

Reference

SFXLinkedHashMap::GetFirstKeyEnumerator | SFXLinkedHashMap::GetFirstValueEnumerator | SFXLinkedHashMap::GetFirstValueIterator | SFXLinkedHashMap::ValueEnumerator | SFXLinkedHashMap::ValueIterator | SFXLinkedHashMap::KeyEnumerator | SFXLinkedHashMap::KeyIterator


SFXLinkedHashMap::GetFirstValueEnumerator
Get the value enumerator that points to the value of the first pair element.
[ public, const ]
ValueEnumerator GetFirstValueEnumerator(Void);

Return value

Value enumerator that points to the value of the first pair element

Description

This function gets the value enumerator of this hashmap that points to the value of the first pair element.

Reference

SFXLinkedHashMap::GetFirstValueIterator | SFXLinkedHashMap::GetFirstKeyIterator | SFXLinkedHashMap::GetFirstKeyEnumerator | SFXLinkedHashMap::ValueEnumerator | SFXLinkedHashMap::ValueIterator | SFXLinkedHashMap::KeyEnumerator | SFXLinkedHashMap::KeyIterator


SFXLinkedHashMap::GetFirstValueIterator
Get the value iterator that points to the value of the first pair element.
[ public ]
ValueIterator GetFirstValueIterator(Void);

Return value

Value iterator that points to the value of the first pair element

Description

This function gets the value iterator of this hashmap that points to the value of the first pair element.

Reference

SFXLinkedHashMap::GetFirstValueEnumerator | SFXLinkedHashMap::GetFirstKeyIterator | SFXLinkedHashMap::GetFirstKeyEnumerator | SFXLinkedHashMap::ValueEnumerator | SFXLinkedHashMap::ValueIterator | SFXLinkedHashMap::KeyEnumerator | SFXLinkedHashMap::KeyIterator


SFXLinkedHashMap::GetKeyEnumerator
Get the key enumerator that points to the key of the pair element at the specified index.
[ public, const ]
KeyEnumerator GetKeyEnumerator(
    SInt32 index   // index to start
);
[ public, const ]
KeyEnumerator GetKeyEnumerator(Void);

Return value

Key enumerator that points to the key of the pair element at the specified index

Description

This function gets the key enumerator of this hashmap that points to the key of the pair element at the specified index.

[Note] Note

If the specified index is less than or equals 0, this function is same as the SFXLinkedHashMap::GetFirstKeyEnumerator function.

If the specified index is more than or equals the size of this hashmap, this function is same as the SFXLinkedHashMap::GetLastKeyEnumerator function.

If no argument is specified, this function is same as SFXLinkedHashMap::GetFirstKeyEnumerator.

Reference

SFXLinkedHashMap::GetFirstKeyEnumerator | SFXLinkedHashMap::GetLastKeyEnumerator | SFXLinkedHashMap::GetKeyIterator | SFXLinkedHashMap::GetValueIterator | SFXLinkedHashMap::GetValueEnumerator | SFXLinkedHashMap::ValueEnumerator | SFXLinkedHashMap::ValueIterator | SFXLinkedHashMap::KeyEnumerator | SFXLinkedHashMap::KeyIterator


SFXLinkedHashMap::GetKeyIterator
Get the key iterator that points to the key of the pair element at the specified index.
[ public ]
KeyIterator GetKeyIterator(
    SInt32 index   // index to start
);
[ public ]
KeyIterator GetKeyIterator(Void);

Return value

Key iterator that points to the key of the pair element at the specified index

Description

This function gets the key iterator of this hashmap that points to the key of the pair element at the specified index.

[Note] Note

If the specified index is less than or equals 0, this function is same as the SFXLinkedHashMap::GetFirstKeyIterator function.

If the specified index is more than or equals the size of this hashmap, this function is same as the SFXLinkedHashMap::GetLastKeyIterator function.

If no argument is specified, this function is same as SFXLinkedHashMap::GetFirstKeyIterator.

Reference

SFXLinkedHashMap::GetFirstKeyIterator | SFXLinkedHashMap::GetLastKeyIterator | SFXLinkedHashMap::GetKeyEnumerator | SFXLinkedHashMap::GetValueEnumerator | SFXLinkedHashMap::GetValueIterator | SFXLinkedHashMap::ValueEnumerator | SFXLinkedHashMap::ValueIterator | SFXLinkedHashMap::KeyEnumerator | SFXLinkedHashMap::KeyIterator


SFXLinkedHashMap::GetLastKeyEnumerator
Get the key enumerator that points to the key of the last pair element.
[ public, const ]
KeyEnumerator GetLastKeyEnumerator(Void);

Return value

Key enumerator that points to the key of the last pair element

Description

This function gets the key enumerator of this hashmap that points to the key of the last pair element.

Reference

SFXLinkedHashMap::GetLastKeyIterator | SFXLinkedHashMap::GetLastValueIterator | SFXLinkedHashMap::GetLastValueEnumerator | SFXLinkedHashMap::ValueEnumerator | SFXLinkedHashMap::ValueIterator | SFXLinkedHashMap::KeyEnumerator | SFXLinkedHashMap::KeyIterator


SFXLinkedHashMap::GetLastKeyIterator
Get the key iterator that points to the key of the last pair element.
[ public ]
KeyIterator GetLastKeyIterator(Void);

Return value

Key iterator that points to the key of the last pair element

Description

This function gets the key iterator of this hashmap that points to the key of the last pair element.

Reference

SFXLinkedHashMap::GetLastKeyEnumerator | SFXLinkedHashMap::GetLastValueEnumerator | SFXLinkedHashMap::GetLastValueIterator | SFXLinkedHashMap::ValueEnumerator | SFXLinkedHashMap::ValueIterator | SFXLinkedHashMap::KeyEnumerator | SFXLinkedHashMap::KeyIterator


SFXLinkedHashMap::GetLastValueEnumerator
Get the value enumerator that points to the value of the last pair element.
[ public, const ]
ValueEnumerator GetLastValueEnumerator(Void);

Return value

Value enumerator that points to the value of the last pair element

Description

This function gets the value enumerator of this hashmap that points to the value of the last pair element.

Reference

SFXLinkedHashMap::GetLastValueIterator | SFXLinkedHashMap::GetLastKeyIterator | SFXLinkedHashMap::GetLastKeyEnumerator | SFXLinkedHashMap::ValueEnumerator | SFXLinkedHashMap::ValueIterator | SFXLinkedHashMap::KeyEnumerator | SFXLinkedHashMap::KeyIterator


SFXLinkedHashMap::GetLastValueIterator
Get the value iterator that points to the value of the last pair element.
[ public ]
ValueIterator GetLastValueIterator(Void);

Return value

Value iterator that points to the value of the last pair element

Description

This function gets the value iterator of this hashmap that points to the value of the last pair element.

Reference

SFXLinkedHashMap::GetLastValueEnumerator | SFXLinkedHashMap::GetLastKeyIterator | SFXLinkedHashMap::GetLastKeyEnumerator | SFXLinkedHashMap::ValueEnumerator | SFXLinkedHashMap::ValueIterator | SFXLinkedHashMap::KeyEnumerator | SFXLinkedHashMap::KeyIterator


SFXLinkedHashMap::GetRatio
[DEPRECATED] Get the expansion ratio of hash table size.
[ public, const ]
UInt16 GetRatio(Void);

Return value

Always return 0.

Description

This function always returns 0.

This API exists only for the compatibility with the SFXOldHashmap class which had been called as SFXHashmap in SophiaFramework UNIVERSE 5.1.8 or below.

[Note] DEPRECATED

It is recommended not to use this API since it will be deprecated in SophiaFramework UNIVERSE 6.0.

Reference

SFXLinkedHashMap::SetRatio


SFXLinkedHashMap::GetSize
Get the size of this hashmap.
[ public, const ]
SInt32 GetSize(Void);

Return value

Size of this hashmap

Description

This function gets the size of this hashmap(i.e., the number of the key-value pair elements of this hashmap).


SFXLinkedHashMap::GetThreshold
[DEPRECATED] Get the threshold to expand the hash table size.
[ public, const ]
UInt16 GetThreshold(Void);

Return value

Always return 45. [unit: %]

Description

This function always returns 45. [unit: %]

This API exists only for the compatibility with the SFXOldHashmap class which had been called as SFXHashmap in SophiaFramework UNIVERSE 5.1.8 or below.

[Note] DEPRECATED

It is recommended not to use this API since it will be deprecated in SophiaFramework UNIVERSE 6.0.

Reference

SFXLinkedHashMap::SetThreshold


SFXLinkedHashMap::GetValueEnumerator
Get the value enumerator that points to the value of the pair element at the specified index.
[ public, const ]
ValueEnumerator GetValueEnumerator(
    SInt32 index   // index to start
);
[ public, const ]
ValueEnumerator GetValueEnumerator(Void);

Return value

Value enumerator that points to the value of the pair element at the specified index

Description

This function gets the value enumerator of this hashmap that points to the value of the pair element at the specified index.

[Note] Note

If the specified index is less than or equals 0, this function is same as the SFXLinkedHashMap::GetFirstValueEnumerator function.

If the specified index is more than or equals the size of this hashmap, this function is same as the SFXLinkedHashMap::GetLastValueEnumerator function.

If no argument is specified, this function is same as SFXLinkedHashMap::GetFirstValueEnumerator.

Reference

SFXLinkedHashMap::GetFirstValueEnumerator | SFXLinkedHashMap::GetLastValueEnumerator | SFXLinkedHashMap::GetValueIterator | SFXLinkedHashMap::GetKeyIterator | SFXLinkedHashMap::GetKeyEnumerator | SFXLinkedHashMap::ValueEnumerator | SFXLinkedHashMap::ValueIterator | SFXLinkedHashMap::KeyEnumerator | SFXLinkedHashMap::KeyIterator


SFXLinkedHashMap::GetValueIterator
Get the value iterator that points to the value of the pair element at the specified index.
[ public ]
ValueIterator GetValueIterator(
    SInt32 index   // starting index of the value iterator
);
[ public ]
ValueIterator GetValueIterator(Void);

Return value

Value iterator that points to the value of the pair element at the specified index

Description

This function gets the value iterator of this hashmap that points to the value of the pair element at the specified index.

[Note] Note

If the specified index is less than or equals 0, this function is same as the SFXLinkedHashMap::GetFirstValueIterator function.

If the specified index is more than or equals the size of this hashmap, this function is same as the SFXLinkedHashMap::GetLastValueIterator function.

If no argument is specified, this function is same as SFXLinkedHashMap::GetFirstValueIterator.

Reference

SFXLinkedHashMap::GetFirstValueIterator | SFXLinkedHashMap::GetLastValueIterator | SFXLinkedHashMap::GetValueEnumerator | SFXLinkedHashMap::GetKeyIterator | SFXLinkedHashMap::GetKeyEnumerator | SFXLinkedHashMap::ValueEnumerator | SFXLinkedHashMap::ValueIterator | SFXLinkedHashMap::KeyEnumerator | SFXLinkedHashMap::KeyIterator


SFXLinkedHashMap::IsEmpty
Check whether or not this hashmap is empty.
[ public, const ]
Bool IsEmpty(Void);

Return value

  • If yes: true
  • Otherwise: false

Description

This function checks whether or not this hashmap is empty.


SFXLinkedHashMap::Merge
Merge this hashmap with the specified hashmap.
[ public ]
SFCError Merge(
    SFXLinkedHashMap< K, V > const & collection   // hashmap to merge
);

Return value

  • If succeeds: SFERR_NO_ERROR
  • If insufficient memory: SFERR_NO_MEMOERY

Description

This function merges this hashmap with the specified this hashmap.

* In case an error occurs during processing, this hashmap will be restored.


SFXLinkedHashMap::Remove
Remove the key-value pair with the specified key from this hashmap.
[ public ]
Void Remove(
    KeyType key   // key to remove
);

Description

This function removes the key-value pair with the specified key from this hashmap.

If the key is of the SFXAnsiString / SFXWideString type, the string as the key will be released automatically.

[Caution] Caution

If the key or the value is a pointer to a class instance or data bigger than 4 bytes, data the pointer points to will not be released automatically.

These data need to be released explicitly using the delete statement. Otherwise, memory leakage will occur.

Reference

SFXLinkedHashMap::Set | SFXLinkedHashMap::Clear


SFXLinkedHashMap::Set
Set the specified key-value pair or hashmap into this hashmap.
[ public ]
SFCError Set(
    SFXLinkedHashMap< K, V > const & collection   // hashmap to set
);
[ public ]
SFCError Set(
    KeyType key       // key to set
    ValueType value   // value to set
);

Return value

  • If succeeds: SFERR_NO_ERROR
  • If insufficient memory: SFERR_NO_MEMOERY
  • If the key is the null string: SFERR_INVALID_PARAM

Description

This function sets the specified key-value pair or hashmap into this hashmap.

* In case an error occurs during processing, this hashmap will be restored.

[Note] Null string

The null string is the return value of the SFXAnsiString::EmptyInstance / SFXWideString::EmptyInstance function.

Example

SFXLinkedHashMap<SFXAnsiString, SInt32> strmap;

// set a key-value pair element of (key: "mike", value: 2) into the hashmap
if (strmap.Set("mike", 2) == SFERR_NO_ERROR) {

    // set a key-value pair element of (key: "john", value: 1) into the hashmap
    if (strmap.Set("john", 1) == SFERR_NO_ERROR) {
    
        // check whether or not this hashmap contains the key-value pair with the specified key
        TRACE("ContainsKey(\"mike\") = %s", (strmap.ContainsKey("mike")) ? ("true") : ("false"));  // containsKey("mike") = true
        TRACE("ContainsKey(\"tom\") = %s", (strmap.ContainsKey("tom")) ? ("true") : ("false"));    // containsKey("tom") = false
    }
}

Reference

SFXLinkedHashMap::Get | SFXLinkedHashMap::operator[] | SFXAnsiString::EmptyInstance | SFXWideString::EmptyInstance


SFXLinkedHashMap::SetRatio
[DEPRECATED] Set the expansion ratio of hash table size.
[ public ]
Void SetRatio(
    UInt16 ratio   // unused
);

Description

This function does nothing.

This API exists only for the compatibility with the SFXOldHashmap class which had been called as SFXHashmap in SophiaFramework UNIVERSE 5.1.8 or below.

[Note] DEPRECATED

It is recommended not to use this API since it will be deprecated in SophiaFramework UNIVERSE 6.0.

Reference

SFXLinkedHashMap::GetRatio


SFXLinkedHashMap::SetThreshold
[DEPRECATED] Set the threshold to expand the hash table size.
[ public ]
Void SetThreshold(
    UInt16 threshold   // unused
);

Description

This function does nothing.

This API exists only for the compatibility with the SFXOldHashmap class which had been called as SFXHashmap in SophiaFramework UNIVERSE 5.1.8 or below.

[Note] DEPRECATED

It is recommended not to use this API since it will be deprecated in SophiaFramework UNIVERSE 6.0.

Reference

SFXLinkedHashMap::GetThreshold


SFXLinkedHashMap::Swap
Swap the value of two pair elements with the specified keys.
[ public ]
SFCError Swap(
    KeyType destination   // destination key
    KeyType source        // source key
);

Return value

  • If succeeds: SFERR_NO_ERROR
  • If no pair element with the specified key exists: SFERR_INVALID_PARAM

Description

This function swaps the value of two pair elements with the specified keys.

Example

SFXLinkedHashMap<SFXAnsiString, SInt32> strmap;

// set a key-value pair element of (key: "mike", value: 2) into the hashmap
if (strmap.Set("mike", 2) == SFERR_NO_ERROR) {

    // set a key-value pair element of (key: "john", value: 1) into the hashmap
    if (strmap.Set("john", 1) == SFERR_NO_ERROR) {

        // swap the values of two pair elements
        if (strmap.Swap("mike", "john") == SFERR_NO_ERROR) {

            // display the value of the pair element with "mike" as the key on BREW Output Window
            TRACE("%d", strmap.Get("mike"));  // 1
        }
    }
}

SFXLinkedHashMap::operator[]
Get the value of the key-value pair with the specified key index from this hashmap.
[ public, const ]
ValueType operator[](
    KeyType key   // key index to get
);

Return value

If there is the key-value pair with the specified key index in this hashmap, the corresponding value will be returned.

Otherwise, null or 0 will be returned.

Description

This operator gets the value of the key-value pair with the specified key from this hashmap.

[Caution] Caution
In case no key-value pair with the specified key exists, no error will occur but this operator will return 0 or null.

Reference

SFXLinkedHashMap::Get | SFXLinkedHashMap::Set


SFXLinkedHashMap::DefaultEnum
[DEPRECATED] Default threshold to expand the hash table.
enum DefaultEnum {
    DEFAULT_THRESHOLD = 45     // default threshold value to expand the hash table
};

Reference

SFXLinkedHashMap::SetThreshold | SFXLinkedHashMap::GetThreshold


SFXLinkedHashMap::KeyEnumerator
Class for managing the key enumerator for the keys of the pair elements of this hashmap.
[ public ]

SFMTYPEDEFCLASS(KeyEnumerator)
class KeyEnumerator {
    public:
        explicit            KeyEnumerator           (Void);
                            KeyEnumerator           (KeyIteratorConstRef iterator);
        KeyEnumeratorRef    operator=               (KeyIteratorConstRef iterator);
        KeyType             GetNext                 (Void);
        KeyType             GetPrevious             (Void);
        ValueType           GetValue                (Void) const;
        Bool                HasNext                 (Void) const;
        Bool                HasPrevious             (Void) const;
        Bool                IsValid                 (Void) const;
};

Description

This class is for managing the key enumerator for the keys of the pair elements of this hashmap.

This class has the following member functions.

GetNext Get the next element. If no next element exists, null or 0 will be returned.
GetPrevious Get the previous element. If no previous element exists, null or 0 will be returned.
HasNext Check whether or not the next element exists.
HasPrevious Check whether or not the previous element exists.
IsValid Check whether or not the enumerator is valid.

Reference

SFXLinkedHashMap::KeyIterator | SFXLinkedHashMap::ValueEnumerator | SFXLinkedHashMap::ValueIterator | SFXLinkedHashMap::GetKeyEnumerator | SFXLinkedHashMap::GetKeyIterator | SFXLinkedHashMap::GetValueEnumerator | SFXLinkedHashMap::GetValueIterator


SFXLinkedHashMap::KeyIterator
Class for managing the key iterator for the keys of the pair elements of this hashmap.
[ public ]

SFMTYPEDEFCLASS(KeyIterator)
class KeyIterator  {
    public:
        explicit            KeyIterator             (Void);
 SFCError     SetValue                (ValueType value);
        KeyType             GetNext                 (Void);
        KeyType             GetPrevious             (Void);
        ValueType           GetValue                (Void) const;
        Bool                HasNext                 (Void) const;
        Bool                HasPrevious             (Void) const;
        Bool                IsValid                 (Void) const;
 SFCError            Insert                  (KeyType key, ValueType value);
        Void                Remove                  (Void);
};

Description

This class is for managing the key iterator for the keys of the pair elements of this hashmap.

This class has the following member functions.

SetValue Set a value to the value element of current iterator.
GetNext Get the next element. If no next element exists, null or 0 will be returned.
GetPrevious Get the previous element. If no previous element exists, null or 0 will be returned.
GetValue Get the value element of current iterator. If invalid, return null.
HasNext Check whether or not the next element exists.
HasPrevious Check whether or not the previous element exists.
IsValid Check whether or not the iterator is valid.
Insert Insert a new element at the next element of current iterator.
Remove Remove the element of current iterator.

Reference

SFXLinkedHashMap::KeyEnumerator | SFXLinkedHashMap::ValueEnumerator | SFXLinkedHashMap::ValueIterator | SFXLinkedHashMap::GetKeyEnumerator | SFXLinkedHashMap::GetKeyIterator | SFXLinkedHashMap::GetValueEnumerator | SFXLinkedHashMap::GetValueIterator


SFXLinkedHashMap::ValueEnumerator
Class for managing the value enumerator for the values of the pair elements of this hashmap.
[ public ]

SFMTYPEDEFCLASS(ValueEnumerator)
class ValueEnumerator  {
    public:
        explicit            ValueEnumerator         (Void);
                            ValueEnumerator         (ValueIteratorConstRef iterator);
        ValueEnumeratorRef  operator=               (ValueIteratorConstRef iterator);
        ValueType           GetNext                 (Void);
        ValueType           GetPrevious             (Void);
        KeyType             GetKey                  (Void) const;
        Bool                HasNext                 (Void) const;
        Bool                HasPrevious             (Void) const;
        Bool                IsValid                 (Void) const;
};

Description

This class is for managing the value enumerator for the values of the pair elements of this hashmap.

This class has the following member functions.

GetNext Get the next element. If no next element exists, null or 0 will be returned.
GetPrevious Get the previous element. If no previous element exists, null or 0 will be returned.
HasNext Check whether or not the next element exists.
HasPrevious Check whether or not the previous element exists.
IsValid Check whether or not the enumerator is valid.

Reference

SFXLinkedHashMap::ValueIterator | SFXLinkedHashMap::KeyEnumerator | SFXLinkedHashMap::KeyIterator | SFXLinkedHashMap::GetKeyEnumerator | SFXLinkedHashMap::GetKeyIterator | SFXLinkedHashMap::GetValueEnumerator | SFXLinkedHashMap::GetValueIterator


SFXLinkedHashMap::ValueIterator
Class for managing the value iterator for the values of the pair elements of this hashmap.
[ public ]

SFMTYPEDEFCLASS(ValueIterator)
class ValueIterator  {
    public:
        explicit            ValueIterator           (Void);
 SFCError     Set                     (ValueType value);
        ValueType           GetNext                 (Void);
        ValueType           GetPrevious             (Void);
        KeyType             GetKey                  (Void) const;
        Bool                HasNext                 (Void) const;
        Bool                HasPrevious             (Void) const;
        Bool                IsValid                 (Void) const;
 SFCError            Insert                  (KeyType key, ValueType value);
        Void                Remove                  (Void);
};

Description

This class is for managing the value iterator for the values of the pair elements of this hashmap.

This class has the following member functions.

Set Set a value to the value element of current iterator.
GetNext Get the next element. If no next element exists, null or 0 will be returned.
GetPrevious Get the previous element. If no previous element exists, null or 0 will be returned.
GetKey Get the key element of current iterator. If invalid, return null.
HasNext Check whether or not the next element exists.
HasPrevious Check whether or not the previous element exists.
IsValid Check whether or not the iterator is valid.
Insert Insert a new element at the next element of current iterator.
Remove Remove the element of current iterator.

Reference

SFXLinkedHashMap::ValueEnumerator | SFXLinkedHashMap::KeyEnumerator | SFXLinkedHashMap::KeyIterator | SFXLinkedHashMap::GetKeyEnumerator | SFXLinkedHashMap::GetKeyIterator | SFXLinkedHashMap::GetValueEnumerator | SFXLinkedHashMap::GetValueIterator