Module Data.Iterators

Provide Iterators for String and JArray

Imports

Table of Content

Definitions

data StringIterator a

A StringIterator is a data structure that lets us view a part of a String as a list.

With large Strings, performing list work on Strings can be expensive, because more recent JVMs implement the substring operation via copying.

Construction, ListView.drop, ListView.take, ListView.head and ListView.tail on a StringIterator are O(1) operations. The drawback is that it holds on to the underlying String.

Constructors

private SI {string ∷ StringJ a, at ∷ Int, limit ∷ Int}

Member Functions

at ∷ StringIterator α → Int

access field at

from ∷ StringJ α → StringIterator α

Construct a StringIterator from a String

limit ∷ StringIterator α → Int

access field limit

string ∷ StringIterator α → StringJ α

access field string

to ∷ StringIterator α → StringJ α

realize the substring indicated by this iterator

data ArrayIterator a

A ArrayIterator is a data structure that lets us view a part of a JArray as a list.

With large JArrays, doing ListSource.toList and iterating through the list can get expensive memory-wise.

Construction, ListView.drop, ListView.take, ListView.head and ListView.tail on a ArrayIterator are O(1) operations with a minimal memory overhead. The drawback is that it holds on to the underlying JArray.

Constructors

private AI {array ∷ JArray a, at ∷ Int, limit ∷ Int}

Member Functions

array ∷ ArrayIterator α → JArray α

access field array

at ∷ ArrayIterator α → Int

access field at

from ∷ JArray α → ArrayIterator α

make iterator from JArray

limit ∷ ArrayIterator α → Int

access field limit

to ∷ ArrayElement a ⇒ ArrayIterator a → JArray a

realize the subarray indicated by this iterator

Instances

instance ListMonoid StringIterator

Member Functions

++ ∷ StringIterator α → StringIterator α → StringIterator α
infixr  13

concatenate the strings described by two iterators

concat ∷ [StringIterator α] → StringIterator α

inherited from ListMonoid.concat

instance ListView ArrayIterator

Member Functions

drop ∷ Int → ArrayIterator α → ArrayIterator α

drop at most n characters by advancing the start index.

Can be abused to "go back" towards the beginning of the String

empty ∷ ArrayIterator α

create an empty ArrayIterator

head ∷ ArrayIterator α → α

inherited from ListView.head

length ∷ ArrayIterator α → Int

length

null ∷ ArrayIterator α → Bool

is it null?

tail ∷ ArrayIterator α → ArrayIterator α

inherited from ListView.tail

take ∷ Int → ArrayIterator α → ArrayIterator α

sets the ListView.length of the projection to n or 0, if n is negative.

toList ∷ ArrayIterator α → [α]

inherited from ListView.toList

uncons ∷ ArrayIterator α → Maybe (α, ArrayIterator α)

deconstruct

instance ListView StringIterator

Member Functions

drop ∷ Int → StringIterator α → StringIterator α

drop at most n characters by advancing the start index.

Can be abused to "go back" towards the beginning of the String

empty ∷ StringIterator α

empty StringIterator

head ∷ StringIterator α → α

inherited from ListView.head

length ∷ StringIterator α → Int

length

null ∷ StringIterator α → Bool

is it null?

tail ∷ StringIterator α → StringIterator α

inherited from ListView.tail

take ∷ Int → StringIterator α → StringIterator α

sets the ListView.length of the projection to n or 0, if n is negative.

toList ∷ StringIterator α → [α]

inherited from ListView.toList

uncons ∷ StringIterator α → Maybe (α, StringIterator α)

deconstruct

Functions and Values by Type

ArrayIterator α → (Int→Int) → ArrayIterator α

ArrayIterator.chg$at, ArrayIterator.chg$limit

ArrayIterator α → Int → ArrayIterator α

ArrayIterator.upd$at, ArrayIterator.upd$limit

ArrayIterator α → ArrayIterator α

ListView_ArrayIterator.tail

ArrayIterator α → JArray α

ArrayIterator.array

ArrayIterator α → Maybe (α, ArrayIterator α)

ListView_ArrayIterator.uncons

ArrayIterator α → [α]

ListView_ArrayIterator.toList

ArrayIterator α → Bool

ListView_ArrayIterator.null

ArrayIterator α → Int

ListView_ArrayIterator.length, ArrayIterator.limit, ArrayIterator.at

ArrayIterator α → α

ListView_ArrayIterator.head

StringIterator α → (Int→Int) → StringIterator α

StringIterator.chg$at, StringIterator.chg$limit

StringIterator α → StringIterator α → StringIterator α

ListMonoid_StringIterator.++

StringIterator α → Int → StringIterator α

StringIterator.upd$limit, StringIterator.upd$at

StringIterator α → StringIterator α

ListView_StringIterator.tail

StringIterator α → Maybe (α, StringIterator α)

ListView_StringIterator.uncons

StringIterator α → StringJ α

StringIterator.to, StringIterator.string

StringIterator α → [α]

ListView_StringIterator.toList

StringIterator α → Bool

ListView_StringIterator.null

StringIterator α → Int

ListView_StringIterator.length, StringIterator.limit, StringIterator.at

StringIterator α → α

ListView_StringIterator.head

JArray a → Int → Int → ArrayIterator a

ArrayIterator.AI

JArray α → ArrayIterator α

ArrayIterator.from

StringJ a → Int → Int → StringIterator a

StringIterator.SI

StringJ α → StringIterator α

StringIterator.from

[StringIterator α] → StringIterator α

ListMonoid_StringIterator.concat

Int → ArrayIterator α → ArrayIterator α

ListView_ArrayIterator.take, ListView_ArrayIterator.drop

Int → StringIterator α → StringIterator α

ListView_StringIterator.take, ListView_StringIterator.drop

α → Bool

ArrayIterator.has$at, ArrayIterator.has$limit, ArrayIterator.has$array, StringIterator.has$string, StringIterator.has$at, StringIterator.has$limit

ArrayElement a ⇒ ArrayIterator a → JArray a

ArrayIterator.to

ArrayIterator α

ListView_ArrayIterator.empty

StringIterator α

ListView_StringIterator.empty

ArrayIterator α → (JArray α→JArray β) → ArrayIterator β

ArrayIterator.chg$array

ArrayIterator α → JArray β → ArrayIterator β

ArrayIterator.upd$array

StringIterator α → (StringJ α→StringJ β) → StringIterator β

StringIterator.chg$string

StringIterator α → StringJ β → StringIterator β

StringIterator.upd$string

Valid HTML 4.01 Strict