Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/griba2001/urweb-aatree
Sorted and Hashed versions of Sets and Dictionaries as Arne Anderson trees in urweb.
https://github.com/griba2001/urweb-aatree
Last synced: 3 months ago
JSON representation
Sorted and Hashed versions of Sets and Dictionaries as Arne Anderson trees in urweb.
- Host: GitHub
- URL: https://github.com/griba2001/urweb-aatree
- Owner: griba2001
- Created: 2015-01-12T15:05:32.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2018-06-11T19:08:49.000Z (over 6 years ago)
- Last Synced: 2024-06-19T23:14:25.090Z (5 months ago)
- Language: UrWeb
- Homepage:
- Size: 244 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-urweb - urweb-aatree - Sorted and Hashed versions of Sets and Dictionaries as Arne Anderson trees (Algorithms and Data Structures)
README
### Sorted Map, Sorted Set, Unordered HashMap, Unordered HashSet functors for Ur/Web
based on Arne Anderson Tree as listed in [wikipedia](https://en.wikipedia.org/wiki/AA_tree).
with tests on inserts, membership after deletes, and AATree properties.
The Haskell version I made first
has been tested with QuickCheck and passes tests for all AATree properties#### to build it
```bash
export C_INCLUDE_PATH=/path-to-your-urweb-installation/include
export LIBRARY_PATH=/path-to-your-urweb-installation/lib# C file used in lib/lib_hashable/src/Hashable for hashTree, hashSet, hashMap
cd lib/lib_bits/src/c
gcc -c Bits.c
cd ../../../..urweb aatree_test_v3
# execution
./aatree_test_v3.exe -p 8081 & # -pbrowser http://localhost:8081/
# when done, if the server has been started in background
killall -TERM aatree_test_v3.exe
```Repeating page retrieval makes the test use different input random data.
--------------------
```bash
# ** an intermediate data structure for hashMap bucketsurweb listMap_test
# test as above.
urweb unordHashTree_test
# test as above.
```---------------------
####Considerations:
Like Haskell instance constraints
```ocaml
functor MkSortedSet(Q: sig
con item :: Type
val ord_item: ord item
end) = struct ... end
```we factor out the "ord item" constraint from the methods signature.
####Example:
```ocaml
structure IntSortedSet = Set.MkSortedSet( struct
type item = int
val ord_item = ord_int
end)structure IntSetOps = SetOps.MkSetOps (IntSortedSet)
val mySortedSet = IntSortedSet.fromList (3 :: 1 :: 2 :: [])
structure HI = Hashable.HashableInstances
structure StringHashedSet = Set.MkUnordHashSet( struct
type item = string
val eq_item = eq_string
val hashable_item = HI.hashable_string
end)structure StringSetOps = SetOps.MkSetOps (StringHashedSet)
val myHashedSet = StringHashedSet.fromList ("ab" :: "cd" :: [])
structure IntKeyedSortedMap = Map.MkSortedMap( struct
type key = int
val ord_key = ord_int
end)structure IntKMapOps = MapOps.MkMapOps (IntKeyedSortedMap)
val mySortedMap = IntKeyedSortedMap.fromList( (1, "ab") :: (2, "cd") :: [])
structure StringKeyedHashMap = Map.MkUnordHashMap( struct
type key = string
val eq_key = eq_string
val hashable_key = HI.hashable_string
end)structure StringKMapOps = MapOps.MkMapOps (StringKeyedHashMap)
val myHashedMap = StringKeyedHashMap.fromList( ("ab", 1) :: ("cd", 2) :: [])
fun main () : transaction page = return
{[mySortedSet]}
{[myHashedSet]}
{[mySortedMap]}
{[myHashedMap]}
```