Copyright | Copyright (c) 2009-2015, David Sorokin <david.sorokin@gmail.com> |
---|---|
License | BSD3 |
Maintainer | David Sorokin <david.sorokin@gmail.com> |
Stability | experimental |
Safe Haskell | None |
Language | Haskell2010 |
Tested with: GHC 7.8.3
This module defines the queue strategies.
- class QueueStrategy s where
- data StrategyQueue s :: * -> *
- newStrategyQueue :: s -> Simulation (StrategyQueue s i)
- strategyQueueNull :: StrategyQueue s i -> Event Bool
- class QueueStrategy s => DequeueStrategy s where
- strategyDequeue :: StrategyQueue s i -> Event i
- class DequeueStrategy s => EnqueueStrategy s where
- strategyEnqueue :: StrategyQueue s i -> i -> Event ()
- class DequeueStrategy s => PriorityQueueStrategy s p | s -> p where
- strategyEnqueueWithPriority :: StrategyQueue s i -> p -> i -> Event ()
- data FCFS = FCFS
- data LCFS = LCFS
- data SIRO = SIRO
- data StaticPriorities = StaticPriorities
Documentation
class QueueStrategy s where Source
Defines the basic queue strategy.
data StrategyQueue s :: * -> * Source
A queue used by the strategy.
:: s | the strategy |
-> Simulation (StrategyQueue s i) | a new queue |
Create a new queue by the specified strategy.
:: StrategyQueue s i | the queue |
-> Event Bool | the result of the test |
Test whether the queue is empty.
QueueStrategy StaticPriorities | An implementation of the |
QueueStrategy SIRO | An implementation of the |
QueueStrategy LCFS | An implementation of the |
QueueStrategy FCFS | An implementation of the |
class QueueStrategy s => DequeueStrategy s where Source
Defines a strategy with support of the dequeuing operation.
:: StrategyQueue s i | the queue |
-> Event i | the dequeued element |
Dequeue the front element and return it.
DequeueStrategy StaticPriorities | An implementation of the |
DequeueStrategy SIRO | An implementation of the |
DequeueStrategy LCFS | An implementation of the |
DequeueStrategy FCFS | An implementation of the |
class DequeueStrategy s => EnqueueStrategy s where Source
It defines a strategy when we can enqueue a single element.
:: StrategyQueue s i | the queue |
-> i | the element to be enqueued |
-> Event () | the action of enqueuing |
Enqueue an element.
EnqueueStrategy SIRO | An implementation of the |
EnqueueStrategy LCFS | An implementation of the |
EnqueueStrategy FCFS | An implementation of the |
class DequeueStrategy s => PriorityQueueStrategy s p | s -> p where Source
It defines a strategy when we can enqueue an element with the specified priority.
strategyEnqueueWithPriority Source
:: StrategyQueue s i | the queue |
-> p | the priority |
-> i | the element to be enqueued |
-> Event () | the action of enqueuing |
Enqueue an element with the specified priority.
PriorityQueueStrategy StaticPriorities Double | An implementation of the |
Strategy: First Come - First Served (FCFS).
Eq FCFS | |
Ord FCFS | |
Show FCFS | |
EnqueueStrategy FCFS | An implementation of the |
DequeueStrategy FCFS | An implementation of the |
QueueStrategy FCFS | An implementation of the |
ResultItemable (ResultValue FCFS) | |
data StrategyQueue FCFS = FCFSQueue (DoubleLinkedList i) |
Strategy: Last Come - First Served (LCFS)
Eq LCFS | |
Ord LCFS | |
Show LCFS | |
EnqueueStrategy LCFS | An implementation of the |
DequeueStrategy LCFS | An implementation of the |
QueueStrategy LCFS | An implementation of the |
ResultItemable (ResultValue LCFS) | |
data StrategyQueue LCFS = LCFSQueue (DoubleLinkedList i) |
Strategy: Service in Random Order (SIRO).
Eq SIRO | |
Ord SIRO | |
Show SIRO | |
EnqueueStrategy SIRO | An implementation of the |
DequeueStrategy SIRO | An implementation of the |
QueueStrategy SIRO | An implementation of the |
ResultItemable (ResultValue SIRO) | |
data StrategyQueue SIRO = SIROQueue (Vector i) |
data StaticPriorities Source
Strategy: Static Priorities. It uses the priority queue.
Eq StaticPriorities | |
Ord StaticPriorities | |
Show StaticPriorities | |
DequeueStrategy StaticPriorities | An implementation of the |
QueueStrategy StaticPriorities | An implementation of the |
PriorityQueueStrategy StaticPriorities Double | An implementation of the |
ResultItemable (ResultValue StaticPriorities) | |
data StrategyQueue StaticPriorities = StaticPriorityQueue (PriorityQueue i) |