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.crInstance Method Summary
- #all?(& : T -> ) : Bool
- #any?(& : T -> ) : Bool
- #count(& : T -> ) : Int32
-
#each_copy_with_index(offset = 0, &) : self
Yields an independent record for every index.
-
#each_with_index(offset = 0, &) : self
Yields the same reused record as
each. -
#find(if_none = nil, & : T -> )
Stops before the matching record can be reused by the next read.
- #find!(& : T -> ) : T
- #first(&)
- #first(count : Int) : Array(T)
- #first : T
- #first? : T | Nil
-
#index(& : T -> ) : Int32 | Nil
Returns an ordinal from the reader's current position.
- #index!(& : T -> ) : Int32
-
#map(& : T -> U) : Array(U) forall U
The block receives a copy; its result must own any data it retains.
-
#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.
- #max_by(& : T -> U) : T forall U
-
#max_by?(& : T -> U) : T | Nil forall U
Keep the winning record alive in case its comparison key borrows from it.
- #min_by(& : T -> U) : T forall U
-
#min_by?(& : T -> U) : T | Nil forall U
Keep the winning record alive in case its comparison key borrows from it.
- #minmax_by(& : T -> U) : Tuple(T, T) forall U
-
#minmax_by?(& : T -> U) : Tuple(T, T) | Tuple(Nil, Nil) forall U
Keep both selected records alive when their comparison keys borrow from them.
- #none?(& : T -> ) : Bool
- #one?(& : T -> ) : Bool
-
#partition(& : T -> ) : Tuple(Array(T), Array(T))
Both results retain records, so each record is copied once.
-
#reject(& : T -> ) : Array(T)
Only matching records need an independent copy.
-
#select(& : T -> ) : Array(T)
Only matching records need an independent copy.
- #sum(initial : U, & : T -> V) forall U, V
-
#sum(& : T -> U) : U forall U
Restrict the accumulator to numeric values so this can use
each. - #to_a : Array(T)
Instance Method Detail
Yields an independent record for every index.
Stops before the matching record can be reused by the next read.
The block receives a copy; its result must own any data it retains.
The block receives a copy; its result must own any data it retains.
Keep the winning record alive in case its comparison key borrows from it.
Keep the winning record alive in case its comparison key borrows from it.
Keep both selected records alive when their comparison keys borrow from them.
Both results retain records, so each record is copied once.