API Reference
Namespaces
| Name | Description |
|---|---|
test |
Classes
| Name | Description |
|---|---|
Item |
The Item struct, contains a value of any kind, and a function to free the value and print the value. |
List |
The List struct, contains a header for size, capacity, and resizing multiple and then a List of Items. |
HashMap |
The HashMap struct, contains a header for size, capacity, and resizing multiple. Has a list of entries and a pointer to a hashing function. |
LinkedList |
|
HashMapItem |
The HashMapItem struct. Contains the key, the value, and a next field for collisions. |
ComplexHashMap |
|
LinkedListNode |
|
ItemValueOperations |
Macros
ITEM_TYPES_MATCH
Typedefs
ItemValueFreeFunction
A function that will be a part of the Item struct, it determines how the Item will be freed.
ItemValuePrintFunction
A function that will be a part of the Item struct, it determines how the Item will be printed, mainly for debugging.
ItemValueToStringFunction
A function that will be a part of the Item struct, it determines how the Item can be converted to a string.
ItemValueReplicateFunction
ItemValueEquivalenceFunction
ItemValueHashFunction
HashFunction
A Function that takes key and a capacity and hashes the key to return an index.
ComplexHashMapItem
Functions
ListFree
Frees the List and all the Items in the List.
Parameters
| Parameter | Type | Description |
|---|---|---|
list |
void * |
The List to free. |
HashMapFree
Frees a HashMap.
Parameters
| Parameter | Type | Description |
|---|---|---|
map |
void * |
The HashMap that should be freed. |
DefaultPrint
PrintString
PrintInt
ListPrint
HashMapPrint
LinkedListPrint
ComplexHashMapPrint
DefaultToString
StringToString
IntToString
ListToString
HashMapToString
LinkedListToString
ComplexHashMapToString
DefaultDuplicate
DuplicateInt
DuplicateString
ListDuplicate
HashMapDuplicate
LinkedListDuplicate
StringEquivalence
IntEquivalence
ListEquivalence
HashMapEquivalence
ComplexHashMapEquivalence
StringHash
IntHash
ListHash
HashMapHash
ComplexHashMapHash
ItemInit
Initializes the Item.
Returns
The initialized Item
Parameters
| Parameter | Type | Description |
|---|---|---|
value |
void * |
The value to put into the Item. |
value_ops |
ItemValueOperations * |
A struct containing operations that can be performed on the value of the Item. |
ItemInitV2
ItemFree
Frees an Item.
Parameters
| Parameter | Type | Description |
|---|---|---|
item |
Item * |
The Item to free. |
ItemPrint
Prints an Item.
Parameters
| Parameter | Type | Description |
|---|---|---|
item |
Item * |
The Item to print. |
ItemToString
Converts and Item to a String, uses the ItemToStringFunction.
Returns
a string representation of the item.
Parameters
| Parameter | Type | Description |
|---|---|---|
item |
Item * |
The Item to convert to string. |
ItemDuplicate
ItemHash
ItemEquivalence
ListInit
Initializes a List.
Returns
The initialized List.
Parameters
| Parameter | Type | Description |
|---|---|---|
initial_capacity |
u_int32_t |
How large for the List to start as. |
resize_multiple |
u_int8_t |
What multiple to resize the list after it reaches capacity. |
ListInitDefault
Initializes a List with sane defaults, see ListInit for more customization.
Returns
The initialized List.
ListAddFirst
Add an Item to the front of the List.
Parameters
| Parameter | Type | Description |
|---|---|---|
list |
List * |
The List to add an Item to. |
item |
Item * |
The Item to add to the List. |
ListAddLast
Add an Item to the last available spot of the List.
Parameters
| Parameter | Type | Description |
|---|---|---|
list |
List * |
The List to add an Item to. |
item |
Item * |
The Item to add to the List. |
ListAddAtIndex
Add an Item to a specific index of the list.
Parameters
| Parameter | Type | Description |
|---|---|---|
list |
List * |
The List to add an Item to. |
item |
Item * |
The Item to add to the List. |
index |
u_int32_t |
The index of the List to place the Item into. |
ListRemoveAtIndex
Remove an Item at a specific index.
Parameters
| Parameter | Type | Description |
|---|---|---|
list |
List * |
The List to remove an Item from. |
index |
u_int32_t |
The index of the List to remove the Item from. |
free |
bool |
Do you want to free the Item as well. |
ListRemoveFirst
Remove the first Item from a List.
Parameters
| Parameter | Type | Description |
|---|---|---|
list |
List * |
The List to remove an Item from. |
ListRemoveLast
Remove the last Item from a List.
Parameters
| Parameter | Type | Description |
|---|---|---|
list |
List * |
The List to remove an Item from. |
ListGetAtIndex
Get an Item from a List at a specific Index.
Returns
The Item from the List at a specific Index.
Parameters
| Parameter | Type | Description |
|---|---|---|
list |
List * |
The List to get an Item from. |
index |
u_int32_t |
The index at which to get an Item from. |
ListGetFirst
Get the first Item from a List.
Returns
The first Item from the specified List.
Parameters
| Parameter | Type | Description |
|---|---|---|
list |
List * |
The List to get an Item from. |
ListPopAtIndex
Get and remove an Item from a List.
Returns
Parameters
| Parameter | Type | Description |
|---|---|---|
list |
List * |
The List to get an Item from. |
index |
u_int32_t |
The index at which to get an Item from. |
ListPopFirst
Pop the First Item from a List.
Returns
Parameters
| Parameter | Type | Description |
|---|---|---|
list |
List * |
The List to get an Item from. |
ListPrintInfo
Print info of the List (current size, etc...).
Parameters
| Parameter | Type | Description |
|---|---|---|
list |
List * |
The List to print info of. |
HashMapItemInit
Initializes as HashMapItem.
Returns
The Initialized HashMapItem.
Parameters
| Parameter | Type | Description |
|---|---|---|
key |
char * |
The string key of HashMapItem. |
item |
Item * |
The corresponding value to the hashed key. |
HashMapItemDuplicate
HashMapItemFree
Frees a HashMapItem, can optional deep free by freeing the Item as well.
Parameters
| Parameter | Type | Description |
|---|---|---|
hashmap_item |
HashMapItem * |
The HashMapItem to free. |
deep |
bool |
If true, will free the Item in the HashMapItem. |
HashMapItemPrint
Prints a HashMapItem.
Parameters
| Parameter | Type | Description |
|---|---|---|
hashmap_item |
HashMapItem * |
The HashMapItem to print. |
HashMapGet
Get a HashMapItem based on a key.
Returns
The HashMapItem from the HashMap (if found).
Parameters
| Parameter | Type | Description |
|---|---|---|
map |
HashMap * |
The HashMap to look into. |
key |
char * |
the key to use to look up the item. |
HashMapInit
HashMap * HashMapInit(u_int32_t initial_capacity, u_int8_t resize_multiple, HashFunction * hashFunction, bool force_lowercase)
Initialize a fresh HashMap.
Returns
The initialized HashMap.
Parameters
| Parameter | Type | Description |
|---|---|---|
initial_capacity |
u_int32_t |
The starting capacity of the HashMap. |
resize_multiple |
u_int8_t |
What resizing multiple to use when the HashMap is at capacity. |
hashFunction |
HashFunction * |
A pointer to a function for hashing string to an index. |
force_lowercase |
bool |
Do we want to force lowercase conversion for all keys. |
HashMapInitDefault
Initialize a fresh HashMap with sane defaults, see HashMapInit for more customization.
Returns
The initialized HashMap.
HashMapInsert
Insert a HashMapItem into a HashMap.
Parameters
| Parameter | Type | Description |
|---|---|---|
map |
HashMap * |
The HashMap that should be inserted into. |
entry |
HashMapItem * |
The HashMapItem entry to be inserted into the HashMap. |
HashMapRemove
Remove a HashMapItem from a HashMap.
Parameters
| Parameter | Type | Description |
|---|---|---|
map |
HashMap * |
The HashMap that will have a HashMapItem removed from. |
key |
char * |
The key of the HashMapItem to be removed. |
HashMapGetValueDirect
Get a value directly from a lookup instead of receiving HashMapItem then unwrapping to Item, then unwarapping to value.
Returns
The direct void * value.
Parameters
| Parameter | Type | Description |
|---|---|---|
map |
HashMap * |
The HashMap to look into. |
key |
char * |
The lookup key. |
LinkedListInit
IsLinkedListEmpty
LinkedListAddToFront
LinkedListAddToBack
LinkedListAddAtIndex
LinkedListFree
LinkedListDeleteAtIndex
LinkedListDeleteBack
LinkedListDeleteFront
ComplexHashMapInit
ComplexHashMapInitDefault
ComplexHashMapFree
ComplexHashMapGet
ComplexHashMapInsert
ComplexHashMapRemove
ComplexHashMapDuplicate
Variables
ItemValueStringOperations
ItemValueIntOperations
ItemValueListOperations
ItemValueHashMapOperations
ItemValueComplexHashMapOperations
ItemValueLinkedListOperations
SL_COLLECTIONS_TYPE_STRING
SL_COLLECTIONS_TYPE_INT
SL_COLLECTIONS_TYPE_LIST
SL_COLLECTIONS_TYPE_HASHMAP
SL_COLLECTIONS_TYPE_COMPLEX_HASHMAP
SL_COLLECTIONS_TYPE_LINKED_LIST
test
Variables
| Return | Name | Description |
|---|---|---|
str |
apple |
|
list |
fruits_list |
|
tuple |
fruits |
apple
fruits_list
fruits
Item
The Item struct, contains a value of any kind, and a function to free the value and print the value.
Public Attributes
| Return | Name | Description |
|---|---|---|
void * |
value |
The value itself. |
const void * |
type_id |
What type is the value, by using const char memory addresses. |
ItemValueOperations * |
value_ops |
Common Operations to be performed on the value. |
value
The value itself.
type_id
What type is the value, by using const char memory addresses.
value_ops
Common Operations to be performed on the value.
List
The List struct, contains a header for size, capacity, and resizing multiple and then a List of Items.
Public Attributes
| Return | Name | Description |
|---|---|---|
u_int32_t |
size |
The current size of the List. |
u_int32_t |
capacity |
The capacity of the List, can be expanded. |
u_int8_t |
resize_multiple |
The resizing multiple of the List, if the list is at capacity, what multiple to resize it |
Item ** |
items |
The list of Items. |
size
The current size of the List.
capacity
The capacity of the List, can be expanded.
resize_multiple
The resizing multiple of the List, if the list is at capacity, what multiple to resize it
items
Type: Item **
The list of Items.
HashMap
The HashMap struct, contains a header for size, capacity, and resizing multiple. Has a list of entries and a pointer to a hashing function.
Public Attributes
| Return | Name | Description |
|---|---|---|
u_int32_t |
size |
The current size (number of entries) of the HashMap. |
u_int32_t |
capacity |
How large the HashMap can get before it needs to be resized. |
u_int8_t |
resize_multiple |
If the HashMap needs to be resized, what should the resizing multiple be |
u_int32_t |
collision_count |
How many collisions have occured. |
HashMapItem ** |
entries |
The List entries in the HashMap. |
HashFunction * |
hashFunction |
The function this HashMap uses to Hash strings. |
bool |
force_lowercase |
Should only lowercase be considered, for example "THIS" and "this" are both hashed to the same value. |
size
The current size (number of entries) of the HashMap.
capacity
How large the HashMap can get before it needs to be resized.
resize_multiple
If the HashMap needs to be resized, what should the resizing multiple be
collision_count
How many collisions have occured.
entries
Type: HashMapItem **
The List entries in the HashMap.
hashFunction
Type: HashFunction *
The function this HashMap uses to Hash strings.
force_lowercase
Should only lowercase be considered, for example "THIS" and "this" are both hashed to the same value.
LinkedList
Public Attributes
| Return | Name | Description |
|---|---|---|
LinkedListNode * |
head |
|
u_int32_t |
size |
head
size
HashMapItem
The HashMapItem struct. Contains the key, the value, and a next field for collisions.
Public Attributes
| Return | Name | Description |
|---|---|---|
char * |
key |
The key for a hashed value. |
Item * |
item |
the item hashed to the key. |
struct hashMapItem * |
next |
If a collision occurs, the next field - linked list for collisions. |
key
The key for a hashed value.
item
Type: Item *
the item hashed to the key.
next
If a collision occurs, the next field - linked list for collisions.
ComplexHashMap
Public Attributes
| Return | Name | Description |
|---|---|---|
u_int32_t |
size |
The current size (number of entries) of the HashMap. |
u_int32_t |
capacity |
How large the HashMap can get before it needs to be resized. |
u_int8_t |
resize_multiple |
If the HashMap needs to be resized, what should the resizing multiple be |
u_int32_t |
collision_count |
How many collisions have occured. |
ComplexHashMapItem ** |
entries |
The List entries in the HashMap. |
size
The current size (number of entries) of the HashMap.
capacity
How large the HashMap can get before it needs to be resized.
resize_multiple
If the HashMap needs to be resized, what should the resizing multiple be
collision_count
How many collisions have occured.
entries
The List entries in the HashMap.
LinkedListNode
Public Attributes
| Return | Name | Description |
|---|---|---|
struct linkedListNode * |
next |
|
Item * |
item |
next
item
Type: Item *
ItemValueOperations
Public Attributes
| Return | Name | Description |
|---|---|---|
ItemValueFreeFunction * |
freeFunction |
A function to free the value. |
ItemValuePrintFunction * |
printFunction |
A function to print the value. |
ItemValueToStringFunction * |
toStringFunction |
A function to turn the value. |
ItemValueReplicateFunction * |
duplicateFunction |
A function deep replicate a value of an item. |
ItemValueHashFunction * |
hashFunction |
A function to hash the structure |
ItemValueEquivalenceFunction * |
equivalenceFunction |
A function to check for equivalency |
freeFunction
Type: ItemValueFreeFunction *
A function to free the value.
printFunction
Type: ItemValuePrintFunction *
A function to print the value.
toStringFunction
Type: ItemValueToStringFunction *
A function to turn the value.
duplicateFunction
A function deep replicate a value of an item.
hashFunction
A function to hash the structure
equivalenceFunction
A function to check for equivalency