Skip to content
This repository has been archived by the owner on Jan 25, 2022. It is now read-only.

complex64-archive/judy-nif-cpp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

65 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

judy-nif-cpp

Erlang Native Implemented Functions around Judy arrays, 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.

1> judy:new().
{judy, <<>>}

judy:insert(Key, Val, JudyArr)

Insert a new value into the array.

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.

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.
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.

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.

About

Erlang NIF for judy arrays [JudyHS]

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published