hunt-searchengine-0.3.0.0: A search and indexing engine.

Safe HaskellSafe-Inferred
LanguageHaskell98

Data.LimitedPriorityQueue

Description

Intermediate data structure for sorting and paging a result set

When sorting a result set by priority and knowing how many results are requested and which "page" of the result set is requested, a priority queue with limited capacity can be used for efficient sorting and paging.

Synopsis

Documentation

data Queue v Source

Instances

Show v => Show (Queue v) 

mkQueue :: Int -> Queue v Source

Create an empty priority queue with a limited capacity. If capacity is < 0, no limit is set

insert :: Ord v => v -> Queue v -> Queue v Source

Insert an element if there is space in the queue or if the element is larger than the smallest element.

reduce :: Ord v => Int -> Queue v -> Queue v Source

Reduce size and capacity of queue by throwing away small elements.

toList :: Ord v => Int -> Int -> Queue v -> [v] Source

fromList :: Ord v => Int -> [v] -> Queue v Source

pageList :: Ord v => Int -> Int -> [v] -> [v] Source

Take a list of scored values, sort it and return a page of the result.

pageList 10 5 xs == take 5 . drop 10 . sortBy snd $ xs

If the length is set to -1 no limit on the page length is set.