Safe HaskellNone

CircularList

Description

A CircularList that uses a linked list based on Data.Vector.

Here are a couple of working/design assumptions ...

  • the inital list is consecutive, means it contains the numbers from 1 to N in a/the given order. And the smallest element is 1.
  • the linked-list will always have one element it: (0,0). With this element in it the CircularList is considered empty. We need this element because Vector is to the base of 0 and our lists are starting with 1.
  • to remove an element from the list the predecessor and the successor need to be re-linked. The element it-self will be marked as deleted by making it point to 0.
  • we will never addinsert an elementitem that is bigger than N.
Synopsis

Documentation

data AlreadyExistsException #

Instances

Instances details
Eq AlreadyExistsException # 
Instance details

Defined in CircularList

Show AlreadyExistsException # 
Instance details

Defined in CircularList

Exception AlreadyExistsException # 
Instance details

Defined in CircularList

data ItemNotFoundException #

Constructors

ItemNotFoundException 

Instances

Instances details
Eq ItemNotFoundException # 
Instance details

Defined in CircularList

Show ItemNotFoundException # 
Instance details

Defined in CircularList

Methods

showsPrec :: Int -> ItemNotFoundException -> ShowS

show :: ItemNotFoundException -> String

showList :: [ItemNotFoundException] -> ShowS

Exception ItemNotFoundException # 
Instance details

Defined in CircularList

Methods

toException :: ItemNotFoundException -> SomeException

fromException :: SomeException -> Maybe ItemNotFoundException

displayException :: ItemNotFoundException -> String

data ListIsEmptyException #

Constructors

ListIsEmptyException 

Instances

Instances details
Eq ListIsEmptyException # 
Instance details

Defined in CircularList

Show ListIsEmptyException # 
Instance details

Defined in CircularList

Methods

showsPrec :: Int -> ListIsEmptyException -> ShowS

show :: ListIsEmptyException -> String

showList :: [ListIsEmptyException] -> ShowS

Exception ListIsEmptyException # 
Instance details

Defined in CircularList

Methods

toException :: ListIsEmptyException -> SomeException

fromException :: SomeException -> Maybe ListIsEmptyException

displayException :: ListIsEmptyException -> String

data OutOfRangeException #

Constructors

OutOfRangeException 

Instances

Instances details
Eq OutOfRangeException # 
Instance details

Defined in CircularList

Show OutOfRangeException # 
Instance details

Defined in CircularList

Methods

showsPrec :: Int -> OutOfRangeException -> ShowS

show :: OutOfRangeException -> String

showList :: [OutOfRangeException] -> ShowS

Exception OutOfRangeException # 
Instance details

Defined in CircularList

Methods

toException :: OutOfRangeException -> SomeException

fromException :: SomeException -> Maybe OutOfRangeException

displayException :: OutOfRangeException -> String

data StackIsEmptyException #

Constructors

StackIsEmptyException 

Instances

Instances details
Eq StackIsEmptyException # 
Instance details

Defined in CircularList

Show StackIsEmptyException # 
Instance details

Defined in CircularList

Methods

showsPrec :: Int -> StackIsEmptyException -> ShowS

show :: StackIsEmptyException -> String

showList :: [StackIsEmptyException] -> ShowS

Exception StackIsEmptyException # 
Instance details

Defined in CircularList

Methods

toException :: StackIsEmptyException -> SomeException

fromException :: SomeException -> Maybe StackIsEmptyException

displayException :: StackIsEmptyException -> String

type Current = Int #

type Item = Int #

data CircularList #

The list.

Constructors

CircularList Current (Vector Item) [Current] 

Instances

Instances details
Eq CircularList # 
Instance details

Defined in CircularList

Methods

(==) :: CircularList -> CircularList -> Bool

(/=) :: CircularList -> CircularList -> Bool

Show CircularList # 
Instance details

Defined in CircularList

Methods

showsPrec :: Int -> CircularList -> ShowS

show :: CircularList -> String

showList :: [CircularList] -> ShowS

fromList :: Int -> [Int] -> CircularList #

Make a new CircularList (of size N) from a list.

toList :: CircularList -> [Int] #

Turn the circular list into a list (from current).

size :: CircularList -> Int #

Get the length of the list.

allocated :: CircularList -> Int #

Get the allocated (max) length of the list.

isEmpty :: CircularList -> Bool #

Check, if list is empty.

isIn :: Int -> CircularList -> Bool #

Check, if item is in the list.

get :: CircularList -> Item #

Get the current element.

forward :: CircularList -> CircularList #

Moving current forward.

insert :: Int -> CircularList -> CircularList #

Insert item into list (after current).

Note: The new item cannot be already in the list. Note: Item needs to be in the range (we do not append to the list).

remove :: CircularList -> CircularList #

Remove the item from the list (after the current item).

move :: Int -> CircularList -> CircularList #

Move current to ...

push :: CircularList -> CircularList #

Push the current item on the stack.

pop :: CircularList -> CircularList #

Pop the stack and move to that item.