heap 0.2.3 → 0.3
raw patch · 2 files changed
+26/−21 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- Data/Heap.hs +17/−18
- heap.cabal +9/−3
Data/Heap.hs view
@@ -17,10 +17,9 @@ Heap, MinHeap, MaxHeap , HeapPolicy(..), MinPolicy, MaxPolicy -- * Query- , null, isEmpty, size, head+ , null, isEmpty, size, head, tail, extractHead -- * Construction , empty, singleton, insert- , tail, extractHead -- * Union , union, unions -- * Filter@@ -29,9 +28,9 @@ , take, drop, splitAt , takeWhile, span, break -- * Conversion- -- ** Lists+ -- ** List , fromList, toList, elems- -- ** Ordered lists+ -- ** Ordered list , fromAscList, toAscList -- * Debugging , check@@ -159,6 +158,20 @@ head = fst . extractHead -- |+-- /O(log n)/. Delete the minimum (depending on the 'HeapPolicy')+-- from the 'Heap'.+tail :: (HeapPolicy p a) => Heap p a -> Heap p a+tail = snd . extractHead++-- |+-- /O(log n)/. Find the minimum (depending on the 'HeapPolicy') and+-- delete it from the 'Heap'. This function is undefined for an+-- empty 'Heap'.+extractHead :: (HeapPolicy p a) => Heap p a -> (a, Heap p a)+extractHead Empty = error "empty Heap"+extractHead (Tree _ x l r) = (x, union l r)++-- | -- /O(1)/. Constructs an empty 'Heap'. empty :: Heap p a empty = Empty@@ -172,20 +185,6 @@ -- /O(log n)/. Insert an element in the 'Heap'. insert :: (HeapPolicy p a) => a -> Heap p a -> Heap p a insert x h = union h (singleton x)---- |--- /O(log n)/. Delete the minimum (depending on the 'HeapPolicy')--- from the 'Heap'.-tail :: (HeapPolicy p a) => Heap p a -> Heap p a-tail = snd . extractHead---- |--- /O(log n)/. Find the minimum (depending on the 'HeapPolicy') and--- delete it from the 'Heap'. This function is undefined for an--- empty 'Heap'.-extractHead :: (HeapPolicy p a) => Heap p a -> (a, Heap p a)-extractHead Empty = error "empty Heap"-extractHead (Tree _ x l r) = (x, union l r) -- | -- Take the lowest @n@ elements in ascending order of the
heap.cabal view
@@ -1,14 +1,19 @@+ Name: heap-Version: 0.2.3+Version: 0.3 Stability: beta-Category: Data, Data Structures++Category: Data Structures Synopsis: Heaps in Haskell Description: A flexible Haskell heap implementation+ License: BSD3 License-File: LICENSE Copyright: (c) 2008, Stephan Friedrichs+ Author: Stephan Friedrichs-Maintainer: stephan[dot]friedrichs[at]tu-bs[dot]de+Maintainer: Stephan Friedrichs (deduktionstheorem at web dot de)+ Build-Type: Custom Cabal-Version: >=1.2 Extra-Source-Files: Tests.lhs, Test/Heap.hs@@ -18,3 +23,4 @@ Exposed-Modules: Data.Heap ghc-options: -Wall Extensions: CPP+