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

atStringIterator αInt

access field at

fromStringJ αStringIterator α

Construct a StringIterator from a String

limitStringIterator αInt

access field limit

stringStringIterator αStringJ α

access field string

toStringIterator α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

arrayArrayIterator αJArray α

access field array

atArrayIterator αInt

access field at

fromJArray αArrayIterator α

make iterator from JArray

limitArrayIterator αInt

access field limit

toArrayElement 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

dropIntArrayIterator αArrayIterator α

drop at most n characters by advancing the start index.

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

emptyArrayIterator α

create an empty ArrayIterator

headArrayIterator α → α

inherited from ListView.head

lengthArrayIterator αInt

length

nullArrayIterator αBool

is it null?

tailArrayIterator αArrayIterator α

inherited from ListView.tail

takeIntArrayIterator αArrayIterator α

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

toListArrayIterator α → [α]

inherited from ListView.toList

unconsArrayIterator αMaybe (α, ArrayIterator α)

deconstruct

instance ListView StringIterator

Member Functions

dropIntStringIterator αStringIterator α

drop at most n characters by advancing the start index.

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

emptyStringIterator α

empty StringIterator

headStringIterator α → α

inherited from ListView.head

lengthStringIterator αInt

length

nullStringIterator αBool

is it null?

tailStringIterator αStringIterator α

inherited from ListView.tail

takeIntStringIterator αStringIterator α

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

toListStringIterator α → [α]

inherited from ListView.toList

unconsStringIterator αMaybe (α, StringIterator α)

deconstruct

Functions and Values by Type

ArrayIterator α → (IntInt) → ArrayIterator α

ArrayIterator.chg$at, ArrayIterator.chg$limit

ArrayIterator α → IntArrayIterator α

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 α → (IntInt) → StringIterator α

StringIterator.chg$at, StringIterator.chg$limit

StringIterator α → StringIterator α → StringIterator α

ListMonoid_StringIterator.++

StringIterator α → IntStringIterator α

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 → IntIntArrayIterator a

ArrayIterator.AI

JArray α → ArrayIterator α

ArrayIterator.from

StringJ a → IntIntStringIterator a

StringIterator.SI

StringJ α → StringIterator α

StringIterator.from

[StringIterator α] → StringIterator α

ListMonoid_StringIterator.concat

IntArrayIterator α → ArrayIterator α

ListView_ArrayIterator.take, ListView_ArrayIterator.drop

IntStringIterator α → 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