The documentation has been changed to mdbook
Check it out: https://rust-lang.github.io/mdBook/index.html
This commit is contained in:
1 parent
4e96d3aba0
commit
062c03091c
107 files changed
+9283
-5280
No files matched your search
@@ -0,0 +1,13 @@
|
||||
# Callbacks
|
||||
|
||||
Every collection can have an optional callback node. In this node there are five functions:
|
||||
|
||||
| | |
|
||||
|-|-|
|
||||
| `create` | Is called when an element was successfully added to the collection |
|
||||
| `read` | Is called when the collection was successfully queried about an element |
|
||||
| `update` | Is called when an element in the collection was successfully updated |
|
||||
| `delete` | Is called when an element was successfully removed from the collection |
|
||||
| `resize` | Is called when the collection was full and successfully resized |
|
||||
|
||||
Check the documentation for each collection to see which functions call which callbacks.
|
||||
@@ -0,0 +1,8 @@
|
||||
# Custom Allocation
|
||||
|
||||
All collections have an allocation node. This node can be modified so that every allocation and de-allocation can be done with custom functions. The allocation node has pointers to functions that correspond to:
|
||||
|
||||
* `calloc`
|
||||
* `free`
|
||||
* `malloc`
|
||||
* `realloc`
|
||||
@@ -0,0 +1,3 @@
|
||||
# Features
|
||||
|
||||
The C Macro Collections Library comes with powerful collections. In this section you will better understand many features that are common to all data structures.
|
||||
@@ -0,0 +1,65 @@
|
||||
# Functions Table
|
||||
|
||||
Functions table are like a methods table for you custom data type. It is a `struct` of function pointers that you will need to define in order to some collections to work. Some functions are optional and others are needed in order to a collection to operate.
|
||||
|
||||
### CMP
|
||||
|
||||
A comparator function is used in sorted collections or when an equality is being checked like when trying to find a certain element in a list. It is responsible for taking two arguments of the same data type and comparing them. The return value is an `int` with the following definitions:
|
||||
|
||||
* Return `1` if the first argument is greater than the second;
|
||||
* Return `0` if the first argument equals the second;
|
||||
* Return `-1` if the first argument is less than the second.
|
||||
|
||||
### CPY
|
||||
|
||||
A copy function is used when a collection is being copied. It can be used to make a deep copy of of your custom data type. It must take a single parameter and return a new copy of that same data type. If this function is absent (`NULL`) the data type will be copied by assignment (for pointers this is a shallow copy).
|
||||
|
||||
### STR
|
||||
|
||||
A string function is responsible for taking a `FILE` pointer and a custom data type and outputting the string representation of that data returning a `bool` indication success or failure. It is useful for debugging.
|
||||
|
||||
### FREE
|
||||
|
||||
The free function is called when a collection is cleared (all elements removed) or freed (all elements removed and freed from memory) and it is responsible for completely freeing all resources that are usually acquired by your data type.
|
||||
|
||||
### HASH
|
||||
|
||||
This function receives a custom data type as parameter and returns a `size_t` hash of that data. Used in hashtables.
|
||||
|
||||
### PRI
|
||||
|
||||
A priority function works much like the comparator function except that it compares the priority between two elements. It is used in collections whose structure is based on the priority of elements and not in their general comparison.
|
||||
|
||||
* Return `1` if the first argument has a greater priority than the second;
|
||||
* Return `0` if the first argument has the same priority as second;
|
||||
* Return `-1` if the first argument has a lower priority than the second.
|
||||
|
||||
The following table shows which functions are required, optional or never used for each Collection:
|
||||
|
||||
| Collection | CMP | CPY | STR | FREE | HASH | PRI |
|
||||
| ---------- | :-: | :-: | :-: | :--: | :--: | :-: |
|
||||
| BidiMap |  |  |  |  |  |  |
|
||||
| Deque |  |  |  |  |  |  |
|
||||
| HashMap |  |  |  |  |  |  |
|
||||
| HashSet |  |  |  |  |  |  |
|
||||
| Heap |  |  |  |  |  |  |
|
||||
| IntervalHeap |  |  |  |  |  |  |
|
||||
| List |  |  |  |  |  |  |
|
||||
| LinkedList |  |  |  |  |  |  |
|
||||
| MultiMap |  |  |  |  |  |  |
|
||||
| MultiSet |  |  |  |  |  |  |
|
||||
| Queue |  |  |  |  |  |  |
|
||||
| SortedList |  |  |  |  |  |  |
|
||||
| Stack |  |  |  |  |  |  |
|
||||
| TreeMap |  |  |  |  |  |  |
|
||||
| TreeSet |  |  |  |  |  |  |
|
||||
|
||||
<br>
|
||||
|
||||
| Color | Label |
|
||||
| :---: | ----- |
|
||||
|  | Required for basic functionality. |
|
||||
|  | Required for specific functions. |
|
||||
|  | Required for non-core specific functions. |
|
||||
|  | Optional. |
|
||||
|  | Not Used. |
|
||||
@@ -0,0 +1,5 @@
|
||||
# Two-Way Iterators
|
||||
|
||||
Every collection comes with an interface of iterators where you can easily access the elements of a collection. These can move at any direction, can start at any 'end' of a collection and can move any amount of steps per iteration. Every collection generated comes with an iterator.
|
||||
|
||||
By design choice these iterators do not support modifications to the collection. If a collection is modified, all iterators that have been initialized will most likely be invalidated and may cause undefined behavior if used afterwards.
|
||||
Reference in new issue
Block a user