parcel | Clownfish |
class variable | CFISH_HASH |
struct symbol | cfish_Hash |
class nickname | cfish_Hash |
header file | Clownfish/Hash.h |
Clownfish::Hash – Hashtable.
Values are stored by reference and may be any kind of Obj.
cfish_Hash* // incremented
cfish_Hash_new(
size_t capacity
);
Return a new Hash.
The number of elements that the hash will be asked to hold initially.
cfish_Hash*
cfish_Hash_init(
cfish_Hash *self,
size_t capacity
);
Initialize a Hash.
The number of elements that the hash will be asked to hold initially.
void
cfish_Hash_Clear(
cfish_Hash *self
);
Empty the hash of all key-value pairs.
void
cfish_Hash_Store(
cfish_Hash *self,
cfish_String *key,
cfish_Obj *value // decremented
);
Store a key-value pair.
void
cfish_Hash_Store_Utf8(
cfish_Hash *self,
char *utf8,
size_t size,
cfish_Obj *value // decremented
);
Store a key-value pair using a raw UTF-8 key.
Pointer to UTF-8 character data of the key.
Size of UTF-8 character data in bytes.
The Obj to store.
cfish_Obj*
cfish_Hash_Fetch(
cfish_Hash *self,
cfish_String *key
);
Fetch the value associated with key
.
Returns: the value, or NULL if key
is not present.
cfish_Obj*
cfish_Hash_Fetch_Utf8(
cfish_Hash *self,
char *utf8,
size_t size
);
Fetch the value associated with a raw UTF-8 key.
Pointer to UTF-8 character data of the key.
Size of UTF-8 character data in bytes.
Returns: the value, or NULL if key
is not present.
cfish_Obj* // incremented
cfish_Hash_Delete(
cfish_Hash *self,
cfish_String *key
);
Attempt to delete a key-value pair from the hash.
Returns: the value if key
exists and thus deletion
succeeds; otherwise NULL.
cfish_Obj* // incremented
cfish_Hash_Delete_Utf8(
cfish_Hash *self,
char *utf8,
size_t size
);
Attempt to delete a key-value pair from the hash.
Pointer to UTF-8 character data of the key.
Size of UTF-8 character data in bytes.
Returns: the value if key
exists and thus deletion
succeeds; otherwise NULL.
bool
cfish_Hash_Has_Key(
cfish_Hash *self,
cfish_String *key
);
Indicate whether the supplied key
is present.
cfish_Vector* // incremented
cfish_Hash_Keys(
cfish_Hash *self
);
Return the Hash’s keys.
cfish_Vector* // incremented
cfish_Hash_Values(
cfish_Hash *self
);
Return the Hash’s values.
size_t
cfish_Hash_Get_Size(
cfish_Hash *self
);
Return the number of key-value pairs.
bool
cfish_Hash_Equals(
cfish_Hash *self,
cfish_Obj *other
);
Equality test.
Returns: true if other
is a Hash with the same key-value pairs as
self
. Keys and values are compared using their respective Equals
methods.
Clownfish::Hash is a Clownfish::Obj.
Copyright © 2010-2015 The Apache Software Foundation, Licensed under the
Apache License, Version 2.0.
Apache Lucy, Lucy, Apache, the Apache feather logo, and the Apache Lucy project logo are trademarks of The
Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their
respective owners.