module HTS::RecordStream(T)

Overview

Collection helpers for readers whose each reuses a record. Implementing readers must provide each_copy for retained results, and records must support clone. A record returned by an early exit from each must continue owning its native storage. Each traversal consumes records from the reader's current position.

Direct including types

Defined in:

hts/record_stream.cr

Instance Method Summary

Instance Method Detail

def all?(& : T -> ) : Bool #

[View source]
def any?(& : T -> ) : Bool #

[View source]
def count(& : T -> ) : Int32 #

[View source]
def each_copy_with_index(offset = 0, &) : self #

Yields an independent record for every index.


[View source]
def each_with_index(offset = 0, &) : self #

Yields the same reused record as each.


[View source]
def find(if_none = nil, & : T -> ) #

Stops before the matching record can be reused by the next read.


[View source]
def find!(& : T -> ) : T #

[View source]
def first(&) #

[View source]
def first(count : Int) : Array(T) #

[View source]
def first : T #

[View source]
def first? : T | Nil #

[View source]
def index(& : T -> ) : Int32 | Nil #

Returns an ordinal from the reader's current position.


[View source]
def index!(& : T -> ) : Int32 #

[View source]
def map(& : T -> U) : Array(U) forall U #

The block receives a copy; its result must own any data it retains.


[View source]
def map_with_index(offset = 0, & : T, Int32 -> U) : Array(U) forall U #

The block receives a copy; its result must own any data it retains.


[View source]
def max_by(& : T -> U) : T forall U #

[View source]
def max_by?(& : T -> U) : T | Nil forall U #

Keep the winning record alive in case its comparison key borrows from it.


[View source]
def min_by(& : T -> U) : T forall U #

[View source]
def min_by?(& : T -> U) : T | Nil forall U #

Keep the winning record alive in case its comparison key borrows from it.


[View source]
def minmax_by(& : T -> U) : Tuple(T, T) forall U #

[View source]
def minmax_by?(& : T -> U) : Tuple(T, T) | Tuple(Nil, Nil) forall U #

Keep both selected records alive when their comparison keys borrow from them.


[View source]
def none?(& : T -> ) : Bool #

[View source]
def one?(& : T -> ) : Bool #

[View source]
def partition(& : T -> ) : Tuple(Array(T), Array(T)) #

Both results retain records, so each record is copied once.


[View source]
def reject(& : T -> ) : Array(T) #

Only matching records need an independent copy.


[View source]
def select(& : T -> ) : Array(T) #

Only matching records need an independent copy.


[View source]
def sum(initial : U, & : T -> V) forall U, V #

[View source]
def sum(& : T -> U) : U forall U #

Restrict the accumulator to numeric values so this can use each.


[View source]
def to_a : Array(T) #

[View source]