CkHashtable class final
Store, look up, remove, enumerate, import, and serialize key/value pairs.
CkHashtable provides a simple key/value collection for
storing string and integer values by key. It can add or replace entries,
look up values, test whether keys exist, remove entries, count items,
enumerate keys, import URL query parameters, serialize values back to a
query string, and save or load the table in XML format.
String and integer values
Store values as strings or integers using straightforward add, replace, and lookup methods.
Fast key lookup
Check whether a key exists and retrieve its value without manually scanning a list or parsing text.
Add, replace, and remove
Maintain a mutable collection by adding new entries, replacing existing values, removing individual keys, or clearing the table.
Enumerate keys
Retrieve the set of keys when application logic needs to loop through the stored entries.
Query string helpers
Import URL query parameters into the table and serialize the table back to a query-string representation.
XML persistence
Save the hashtable to XML or reload it from XML when values need to be persisted or transferred in a simple structured format.
Common pattern:
Use Hashtable when application code needs a small mutable
key/value table, especially for lookup tables, parsed query parameters, or
simple string/integer settings. Add values with AddStr or
AddInt, retrieve them with LookupStr or
LookupInt, and use XML or query-string methods when the table
needs to be saved, loaded, or converted.
For an extended overview, see Hashtable Class Overview.
A CkHashtable owns a native Chilkat object. It is released automatically when the
Dart object is garbage collected, or immediately by dispose. Use it only from
the isolate that created it.
- Implemented types
Constructors
- CkHashtable()
-
Creates a new
CkHashtableobject.
Properties
- count → int
-
The number of entries currently stored in the hashtable.
no setter
- debugLogFilePath ↔ String
-
If set to a file path, this property logs the LastErrorText of each
Chilkat method or property call to the specified file. This logging helps
identify the context and history of Chilkat calls leading up to any crash
or hang, aiding in debugging.
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
- isDisposed → bool
-
Whether dispose has been called on this object.
no setter
- lastErrorHtml → String
-
Provides HTML-formatted information about the last called method or
property. If a method call fails or behaves unexpectedly, check this
property for details. Note that information is available regardless of the
method call's success.
no setter
- lastErrorText → String
-
Provides plain text information about the last called method or property.
If a method call fails or behaves unexpectedly, check this property for
details. Note that information is available regardless of the method
call's success.
no setter
- lastErrorXml → String
-
Provides XML-formatted information about the last called method or
property. If a method call fails or behaves unexpectedly, check this
property for details. Note that information is available regardless of the
method call's success.
no setter
- lastMethodSuccess ↔ bool
-
Indicates the success or failure of the most recent method call:
truemeans success,falsemeans failure. This property remains unchanged by property setters or getters. This method is present to address challenges in checking for null or Nothing returns in certain programming languages. Note: This property does not apply to methods that return integer values or to boolean-returning methods where the boolean does not indicate success or failure.getter/setter pair - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- verboseLogging ↔ bool
-
If set to
true, then the contents of LastErrorText (or LastErrorXml, or LastErrorHtml) may contain more verbose information. The default value isfalse. Verbose logging should only be used for debugging. The potentially large quantity of logged information may adversely affect peformance.getter/setter pair - version → String
-
Version of the component/library, such as "10.1.0"
no setter
Methods
-
addFromXmlSb(
CkStringBuilder sbXml) → void -
Reads hashtable XML previously produced by
ToXmlSbfrom theStringBuilderpassed inARG1and adds the entries to this table. -
addInt(
String key, int value) → void -
Adds an entry whose string key is
ARG1and whose value is the integerARG2. If the key already exists, its previous value is replaced. -
addQueryParams(
String queryParams) → void -
Parses URL query parameters from
ARG1and adds them to the hashtable as string entries. Pass the query component in the following form: -
addStr(
String key, String value) → void -
Adds an entry whose string key is
ARG1and whose value is the stringARG2. If the key already exists, its previous value is replaced. -
clear(
) → void -
Removes every entry from the hashtable. After this call,
Countis0. -
clearWithNewCapacity(
int capacity) → void -
Removes every entry and reinitializes the hashtable with
ARG1buckets. The initial default capacity of a newHashtableobject is521. -
contains(
String key) → bool -
Returns
trueif the hashtable contains the string keyARG1; otherwise returnsfalse. The result tests key existence regardless of the value stored for that key. -
containsIntKey(
int key) → bool -
Returns
trueif the hashtable contains the integer keyARG1; otherwise returnsfalse. -
dispose(
) → void - Releases the native object now instead of waiting for garbage collection.
-
getKeys(
CkStringTable strTable) → void -
Appends all hashtable key strings to the
StringTablepassed inARG1. Existing strings already contained inARG1are not cleared. -
lookupInt(
String key) → int -
Returns the integer value associated with the string key
ARG1. This method is intended for entries stored withAddInt. -
lookupStr(
String key) → String -
Returns the string value associated with the string key
ARG1. This method is intended for entries stored as strings, including entries added byAddStrorAddQueryParams. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
remove(
String key) → bool -
Removes the entry whose string key is
ARG1. -
toQueryString(
) → String - Serializes the hashtable as a URL query string in the following form:
-
toString(
) → String -
A string representation of this object.
override
-
toXmlSb(
CkStringBuilder sbXml) → void -
Serializes the current hashtable to Chilkat's hashtable XML format and
appends the XML to the
StringBuilderpassed inARG1. Existing content in theStringBuilderis preserved.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited