trait _group[A] extends AnyRef
- Alphabetic
- Stream._extend._group
- scala.AnyRef
- scala.Any
- Hide All
- Show All
- Public
- All
Method
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
def
group(test: (A, A) ⇒ Boolean, peekSplit: (A, Boolean) ⇒ Any = (_, _) => ()): ~[~[A]]
Group by test
Group by test
Puts elements in the same group based on a function test for every two consecutive elements
// Putting Ints into groups of 3 (0 to 20).all.group(_ / 3 == _ / 3).tp // Output --------------- ? --------------- ~(0, 1, 2) ~(3, 4, 5) ~(6, 7, 8) ~(9, 10, 11) ~(12, 13, 14) ~(15, 16, 17) ~(18, 19, 20) ---------------
- test
function for two consecutive elements. if 'false' is returned, the second tested element will start a new group
- peekSplit
function to run for each piped element. Boolean parameter indicates if the element starts a new group
- Definition Classes
- _group
-
def
group: ~[~[A]]
Simple grouping
Simple grouping
Puts consecutive elements in the same group if they are
equal
Note: Non consecutive equal elements will end up in different groups. Prior ordering might be needed
def all = ~~(1, 2, 3).flatMap(i => Seq(i, i, i)) all.lp // Prints ~(1, 1, 1, 2, 2, 2, 3, 3, 3) all.group.tp // Prints ------------ ? ------------ ~(1, 1, 1) ~(2, 2, 2) ~(3, 3, 3) ------------
- Definition Classes
- _group
-
def
groupBy(properties: Mapping[A, Any]*): ~[~[A]]
Grouping on properties
Grouping on properties
Puts consecutive elements in the same group if all the specified properties are equal
When properties change, a new group is started
('#' to '|').all.groupBy(_.isLetter, _.isDigit).tp // Output --------------------------------------------------------------------------------- ? --------------------------------------------------------------------------------- ~(#, $, %, &, ', (, ), *, +, ,, -, ., /) ~(0, 1, 2, 3, 4, 5, 6, 7, 8, 9) ~(:, ;, <, =, >, ?, @) ~(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z) ~([, \, ], ^, _, `) ~(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z) ~({, |) ---------------------------------------------------------------------------------
- properties
a set of functions, each indicating an element property
- Definition Classes
- _group
-
def
groupBySize(size: Int): ~[~[A]]
Fixed size groups
Fixed size groups
Puts consecutive elements into fixed size groups
('a' to 'z').all.groupBySize(8).tp // Output ------------------------- ? ------------------------- ~(a, b, c, d, e, f, g, h) ~(i, j, k, l, m, n, o, p) ~(q, r, s, t, u, v, w, x) ~(y, z) -------------------------
- size
of groups. Cannot be less than 1.
- Definition Classes
- _group
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
-
def
partition(groupFilters: Filter[A]*): ~[~[A]]
Multi-filter grouping
Multi-filter grouping
All stream elements are grouped by specified filters
Filters are applied in sequence, thus if an element is accepted into a group, it will not be evaluated by the rest of the filters
If there are elements, which are left without a group, one extra group is created
// Age groups (1 to 80).all.partition(_ <= 12, 13 to 19, _ < 30, 30 to 40, _ < 50, _ < 65).tp // Output ------------------------------------------------------------------- ? ------------------------------------------------------------------- ~(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12) ~(13, 14, 15, 16, 17, 18, 19) ~(20, 21, 22, 23, 24, 25, 26, 27, 28, 29) ~(30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40) ~(41, 42, 43, 44, 45, 46, 47, 48, 49) ~(50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64) ~(65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80) -------------------------------------------------------------------
- groupFilters
a set of filters, to specify groups
- Definition Classes
- _group
-
def
sliding(size: Int, step: Int = 1): ~[~[A]]
Sliding group view
Sliding group view
Example: group size 3 with step 1
('a' to 'g').all.sliding(3).tp // Output ---------- ? ---------- ~(a, b, c) ~(b, c, d) ~(c, d, e) ~(d, e, f) ~(e, f, g) ----------
Example: group size 4 with step 2
('a' to 'g').all.sliding(4,2).tp // Output ------------- ? ------------- ~(a, b, c, d) ~(c, d, e, f) ~(e, f, g) -------------
- Definition Classes
- _group
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
Element Grouping Interface