Copyright | Copyright (c) 2009-2017 David Sorokin <david.sorokin@gmail.com> |
---|---|
License | BSD3 |
Maintainer | David Sorokin <david.sorokin@gmail.com> |
Stability | experimental |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Tested with: GHC 8.0.1
This module defines the queue strategies.
Synopsis
- 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 ()
- class DequeueStrategy s => DeletingQueueStrategy s where
- strategyQueueDelete :: Eq i => StrategyQueue s i -> i -> Event Bool
- strategyQueueDeleteBy :: StrategyQueue s i -> (i -> Bool) -> Event (Maybe i)
- strategyQueueContains :: Eq i => StrategyQueue s i -> i -> Event Bool
- strategyQueueContainsBy :: StrategyQueue s i -> (i -> Bool) -> Event (Maybe i)
- 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.
Instances
QueueStrategy FCFS Source # | An implementation of the |
Defined in Simulation.Aivika.QueueStrategy newStrategyQueue :: FCFS -> Simulation (StrategyQueue FCFS i) Source # strategyQueueNull :: StrategyQueue FCFS i -> Event Bool Source # | |
QueueStrategy LCFS Source # | An implementation of the |
Defined in Simulation.Aivika.QueueStrategy newStrategyQueue :: LCFS -> Simulation (StrategyQueue LCFS i) Source # strategyQueueNull :: StrategyQueue LCFS i -> Event Bool Source # | |
QueueStrategy SIRO Source # | An implementation of the |
Defined in Simulation.Aivika.QueueStrategy newStrategyQueue :: SIRO -> Simulation (StrategyQueue SIRO i) Source # strategyQueueNull :: StrategyQueue SIRO i -> Event Bool Source # | |
QueueStrategy StaticPriorities Source # | An implementation of the |
Defined in Simulation.Aivika.QueueStrategy data StrategyQueue StaticPriorities :: Type -> Type Source # |
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.
Instances
DequeueStrategy FCFS Source # | An implementation of the |
Defined in Simulation.Aivika.QueueStrategy strategyDequeue :: StrategyQueue FCFS i -> Event i Source # | |
DequeueStrategy LCFS Source # | An implementation of the |
Defined in Simulation.Aivika.QueueStrategy strategyDequeue :: StrategyQueue LCFS i -> Event i Source # | |
DequeueStrategy SIRO Source # | An implementation of the |
Defined in Simulation.Aivika.QueueStrategy strategyDequeue :: StrategyQueue SIRO i -> Event i Source # | |
DequeueStrategy StaticPriorities Source # | An implementation of the |
Defined in Simulation.Aivika.QueueStrategy strategyDequeue :: StrategyQueue StaticPriorities i -> Event i Source # |
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.
Instances
EnqueueStrategy FCFS Source # | An implementation of the |
Defined in Simulation.Aivika.QueueStrategy strategyEnqueue :: StrategyQueue FCFS i -> i -> Event () Source # | |
EnqueueStrategy LCFS Source # | An implementation of the |
Defined in Simulation.Aivika.QueueStrategy strategyEnqueue :: StrategyQueue LCFS i -> i -> Event () Source # | |
EnqueueStrategy SIRO Source # | An implementation of the |
Defined in Simulation.Aivika.QueueStrategy strategyEnqueue :: StrategyQueue SIRO i -> i -> Event () Source # |
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.
Instances
PriorityQueueStrategy StaticPriorities Double Source # | An implementation of the |
Defined in Simulation.Aivika.QueueStrategy strategyEnqueueWithPriority :: StrategyQueue StaticPriorities i -> Double -> i -> Event () Source # |
class DequeueStrategy s => DeletingQueueStrategy s where Source #
Defines a strategy with support of the deleting operation.
:: Eq i | |
=> StrategyQueue s i | the queue |
-> i | the element |
-> Event Bool | whether the element was found and removed |
Remove the element and return a flag indicating whether the element was found and removed.
strategyQueueDeleteBy Source #
:: StrategyQueue s i | the queue |
-> (i -> Bool) | the predicate |
-> Event (Maybe i) | the element if it was found and removed |
Remove an element satisfying the predicate and return the element if found.
strategyQueueContains Source #
:: Eq i | |
=> StrategyQueue s i | the queue |
-> i | the element to find |
-> Event Bool | whether the element is contained in the queue |
Detect whether the specified element is contained in the queue.
strategyQueueContainsBy Source #
:: StrategyQueue s i | the queue |
-> (i -> Bool) | the predicate |
-> Event (Maybe i) | the element if it was found |
Detect whether an element satifying the specified predicate is contained in the queue.
Instances
Strategy: First Come - First Served (FCFS).
Instances
Strategy: Last Come - First Served (LCFS)
Instances
Strategy: Service in Random Order (SIRO).
Instances
data StaticPriorities Source #
Strategy: Static Priorities. It uses the priority queue.