Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/griba2001/urweb-pairing-heap
https://github.com/griba2001/urweb-pairing-heap
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/griba2001/urweb-pairing-heap
- Owner: griba2001
- Created: 2015-08-14T09:44:07.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2015-08-30T13:29:42.000Z (about 9 years ago)
- Last Synced: 2024-06-19T23:14:37.169Z (5 months ago)
- Size: 141 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-urweb - urweb-pairing-heap - A pairing heap implementation of a priority queue (Algorithms and Data Structures)
README
# urweb-pairing-heap
minHeap and maxHeap for items and also for pairs (priority, payload)
with functions: findTop, merge, insert, deleteTop, delete, decreaseKey,
empty, null, size, fromList, toList
```ocaml
(* invariants *)val propHeap: t -> bool (* node subHeaps order *)
val propFromToList: eq item -> list item -> bool (* content conservation *)
val propCheckAfterDeletes: eq item -> list item -> bool (* content conservation after deleting half of original list *)
```### Usage
```ocaml
(* max heap: priority to the major *)
structure MaxH = Heap.MkMaxHeap( struct
type item = int
val ord_item = ord_int
end)
val test1 = 1 :: 2 :: 3 :: []val maxPriorityList = MaxH.toList <| MaxH.fromList test1
(* min heap: priority to the minor *)
structure MinH = Heap.MkMinHeap( struct
type item = int
val ord_item = ord_int
end)val test2 = 3 :: 2 :: 1 :: []
val minPriorityList = MinH.toList <| MinH.fromList test2
structure MinHP = HeapOfPairs.MkMinHeapOfPairs (struct
type prio = int
type payload = string
val ord_prio = ord_int
end)val test3 = (3, "c") :: (2, "b") :: (1, "a") :: []
val minPriorityListOfPairs = (MinHP.toList <<< MinHP.fromList) test3
structure MaxHP = HeapOfPairs.MkMaxHeapOfPairs (struct
type prio = int
type payload = string
val ord_prio = ord_int
end)val test4 = (1, "c") :: (2, "b") :: (3, "a") :: []
val maxPriorityListOfPairs = (MaxHP.toList <<< MaxHP.fromList) test4
```### test task
tests lib/test/heap_UnitTest UrUnit assertions
```bash
urweb test1
./test1.exe -p 8082
browser http://localhost:8082
```
Every browser page refresh brings different random input data