Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/johannesh/judy-nif-cpp
Erlang NIF for judy arrays [JudyHS]
https://github.com/johannesh/judy-nif-cpp
Last synced: 3 days ago
JSON representation
Erlang NIF for judy arrays [JudyHS]
- Host: GitHub
- URL: https://github.com/johannesh/judy-nif-cpp
- Owner: complex64-archive
- License: bsd-2-clause
- Archived: true
- Created: 2013-04-24T20:59:56.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2013-04-24T21:00:35.000Z (over 11 years ago)
- Last Synced: 2024-07-30T22:46:58.630Z (4 months ago)
- Language: C
- Homepage:
- Size: 1.85 MB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## judy-nif-cpp
Erlang [Native Implemented Functions](http://www.erlang.org/doc/tutorial/nif.html) around [Judy arrays](http://judy.sourceforge.net/), written in C++.
### Features
Given enough system memory,
- Arbitary number of elements,
- Arbitary size of keys and elements.### Non-Features
- Nested arrays.## Implemented Functions
All NIF functions accessing the underlying array are wrapped with normal functions doing `term()` to `binary()`, and vice versa, translation prior storage or retrieval.The array is modified in-place, and thus _not a functional data structure_.
##### `judy:new()`
Creates a new Judy array resource wrapped in a tuple.
```erlang
1> judy:new().
{judy, <<>>}
```
****##### `judy:insert(Key, Val, JudyArr)`
Insert a new value into the array.```erlang
1> J = judy:new().
{judy, <<>>}
2> judy:insert(key, value, J).
{judy, <<>>}
3> judy:insert(key, value, J).
{judy, <<>>}
```
****##### `judy:remove(Key, JudyArr)`
Remove a key/value from the array.```erlang
1> J = judy:new().
{judy, <<>>}
2> judy:insert(key, value, J).
{judy, <<>>}
3> judy:remove(key, J).
{judy, <<>>}
4> judy:remove(key, J).
{judy, <<>>}
```
****##### `judy:get(Key, JudyArr)`
Retrieve a value from the array.
- Returns the stored value or `{error, Key}` in case the key was not present.```erlang
1> J = judy:new().
{judy, <<>>}
2> judy:insert(key, value, J).
{judy, <<>>}
3> judy:get(key, J).
value
4> judy:get(foo, J).
{error,foo}
```
****##### `judy:mget(Keys, JudyArr)`
Retrieve multiple values from the array.```erlang
1> J = judy:new().
{judy, <<>>}
2> judy:insert(key, value, J).
{judy, <<>>}
3> judy:insert(key2, value2, J).
{judy, <<>>}
4> judy:mget([key, key2, key3], J).
[value,value2,{error,key3}]
```## License
This project, and all contributed code, are licensed under the FreeBSD License. A copy of the license can be found in the repository.