@@ -4531,36 +4531,75 @@ public interface ColumnsSelectionDsl<out T> : ColumnSelectionDsl<T>, SingleColum
4531
4531
public fun <C > ColumnSet<C>.take (n : Int ): ColumnSet <C > = transform { it.take(n) }
4532
4532
public fun <C > ColumnSet<C>.dropLast (n : Int = 1): ColumnSet <C > = transform { it.dropLast(n) }
4533
4533
public fun <C > ColumnSet<C>.takeLast (n : Int ): ColumnSet <C > = transform { it.takeLast(n) }
4534
- public fun <C > ColumnSet<C>.top (): ColumnSet <C > = transform { it.top() }
4534
+
4535
+ @Deprecated(" Use roots() instead" , ReplaceWith (" roots()" ))
4536
+ public fun <C > ColumnSet<C>.top (): ColumnSet <C > = roots()
4537
+
4538
+ /* *
4539
+ * ## Roots
4540
+ *
4541
+ * Returns a sub-set of columns that are roots of the trees of columns.
4542
+ *
4543
+ * In practice, this means that if a column in [this] is a child of another column in [this],
4544
+ * it will not be included in the result.
4545
+ *
4546
+ * TODO example and SingleColumn case
4547
+ */
4548
+ public fun <C > ColumnSet<C>.roots (): ColumnSet <C > = transform { it.roots() }
4549
+
4535
4550
public fun <C > ColumnSet<C>.takeWhile (predicate : ColumnFilter <C >): ColumnSet <C > =
4536
4551
transform { it.takeWhile (predicate) }
4537
4552
4538
4553
public fun <C > ColumnSet<C>.takeLastWhile (predicate : ColumnFilter <C >): ColumnSet <C > =
4539
4554
transform { it.takeLastWhile(predicate) }
4540
4555
4541
- public fun <C > ColumnSet<C>.filter (predicate : ColumnFilter <C >): ColumnSet <C > =
4542
- colsInternal(predicate as ColumnFilter <* >) as ColumnSet <C >
4556
+ public fun <C > ColumnSet<C>.filter (predicate : ColumnFilter <C >): TransformableColumnSet <C > =
4557
+ colsInternal(predicate as ColumnFilter <* >) as TransformableColumnSet <C >
4543
4558
4544
- public fun SingleColumn <* >.nameContains (text : CharSequence ): ColumnSet <* > = cols { it.name.contains(text) }
4545
- public fun <C > ColumnSet<C>.nameContains (text : CharSequence ): ColumnSet <C > = cols { it.name.contains(text) }
4546
- public fun SingleColumn <* >.nameContains (regex : Regex ): ColumnSet <* > = cols { it.name.contains(regex) }
4547
- public fun <C > ColumnSet<C>.nameContains (regex : Regex ): ColumnSet <C > = cols { it.name.contains(regex) }
4548
- public fun SingleColumn <* >.startsWith (prefix : CharSequence ): ColumnSet <* > = cols { it.name.startsWith(prefix) }
4549
- public fun <C > ColumnSet<C>.startsWith (prefix : CharSequence ): ColumnSet <C > = cols { it.name.startsWith(prefix) }
4550
- public fun SingleColumn <* >.endsWith (suffix : CharSequence ): ColumnSet <* > = cols { it.name.endsWith(suffix) }
4551
- public fun <C > ColumnSet<C>.endsWith (suffix : CharSequence ): ColumnSet <C > = cols { it.name.endsWith(suffix) }
4559
+ public fun SingleColumn <* >.nameContains (text : CharSequence ): TransformableColumnSet <* > =
4560
+ cols { it.name.contains(text) }
4552
4561
4553
- public fun <C > ColumnSet<C>.except ( vararg other : ColumnSet < * > ): ColumnSet < * > = except(other.toColumnSet())
4554
- public fun < C > ColumnSet<C>. except ( vararg other : String ): ColumnSet < * > = except(other.toColumnSet())
4562
+ public fun <C > ColumnSet<C>.nameContains ( text : CharSequence ): TransformableColumnSet < C > =
4563
+ cols { it.name.contains(text) }
4555
4564
4556
- public fun <C > ColumnSet<C?>.withoutNulls (): ColumnSet <C > =
4557
- transform { it.filter { ! it.hasNulls() } } as ColumnSet <C >
4565
+ public fun SingleColumn <* >.nameContains (regex : Regex ): TransformableColumnSet <* > = cols { it.name.contains(regex) }
4566
+ public fun <C > ColumnSet<C>.nameContains (regex : Regex ): TransformableColumnSet <C > = cols { it.name.contains(regex) }
4567
+ public fun SingleColumn <* >.startsWith (prefix : CharSequence ): TransformableColumnSet <* > =
4568
+ cols { it.name.startsWith(prefix) }
4569
+
4570
+ public fun <C > ColumnSet<C>.startsWith (prefix : CharSequence ): TransformableColumnSet <C > =
4571
+ cols { it.name.startsWith(prefix) }
4572
+
4573
+ public fun SingleColumn <* >.endsWith (suffix : CharSequence ): TransformableColumnSet <* > =
4574
+ cols { it.name.endsWith(suffix) }
4575
+
4576
+ public fun <C > ColumnSet<C>.endsWith (suffix : CharSequence ): TransformableColumnSet <C > =
4577
+ cols { it.name.endsWith(suffix) }
4578
+
4579
+ public fun <C > ColumnSet<C>.except (vararg other : ColumnSet <* >): TransformableColumnSet <* > = except(other.toColumnSet())
4580
+ public fun <C > ColumnSet<C>.except (vararg other : String ): TransformableColumnSet <* > = except(other.toColumnSet())
4581
+
4582
+ public fun <C > ColumnSet<C?>.withoutNulls (): TransformableColumnSet <C > =
4583
+ transform { it.filter { ! it.hasNulls() } } as TransformableColumnSet <C >
4584
+
4585
+ public infix fun <C > ColumnSet<C>.except (other : ColumnSet <* >): TransformableColumnSet <* > =
4586
+ // createColumnSet {
4587
+ // [email protected] (it).allColumnsExcept(other.resolve(it))
4588
+ // }
4589
+ createTransformableColumnSet(
4590
+ resolver = { context ->
4591
+ this @except.resolve(context).allColumnsExcept(other.resolve(context))
4592
+ },
4593
+ transformResolve = { context, transformer ->
4594
+ transformer.transform(this @except)
4595
+ .resolve(context)
4596
+ .allColumnsExcept(other.resolve(context))
4597
+ },
4598
+ )
4558
4599
4559
- public infix fun <C > ColumnSet<C>.except (other : ColumnSet <* >): ColumnSet <* > =
4560
- createColumnSet { resolve(it).allColumnsExcept(other.resolve(it)) }
4561
4600
4562
- public infix fun <C > ColumnSet<C>.except (selector : ColumnsSelector <T , * >): ColumnSet <C > =
4563
- except(selector.toColumns()) as ColumnSet <C >
4601
+ public infix fun <C > ColumnSet<C>.except (selector : ColumnsSelector <T , * >): TransformableColumnSet <C > =
4602
+ except(selector.toColumns()) as TransformableColumnSet <C >
4564
4603
4565
4604
public operator fun <C > ColumnsSelector <T , C >.invoke (): ColumnSet <C > =
4566
4605
this (this @ColumnsSelectionDsl, this @ColumnsSelectionDsl)
@@ -4971,7 +5010,10 @@ private interface CommonColsOfDocs {
4971
5010
* @param [filter] an optional filter function that takes a column of type [C] and returns `true` if the column should be included.
4972
5011
* @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns of given type that were included by [filter].
4973
5012
*/
4974
- public fun <C > ColumnSet <* >.colsOf (type : KType , filter : (DataColumn <C >) -> Boolean = { true }): TransformableColumnSet <C > =
5013
+ public fun <C > ColumnSet <* >.colsOf (
5014
+ type : KType ,
5015
+ filter : (DataColumn <C >) -> Boolean = { true },
5016
+ ): TransformableColumnSet <C > =
4975
5017
colsInternal { it.isSubtypeOf(type) && filter(it.cast()) } as TransformableColumnSet <C >
4976
5018
4977
5019
/* *
@@ -5053,7 +5095,10 @@ public inline fun <reified C> ColumnSet<*>.colsOf(noinline filter: (DataColumn<C
5053
5095
* @param [filter] an optional filter function that takes a column of type [C] and returns `true` if the column should be included.
5054
5096
* @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns of given type that were included by [filter].
5055
5097
*/
5056
- public fun <C > SingleColumn <* >.colsOf (type : KType , filter : (DataColumn <C >) -> Boolean = { true }): TransformableColumnSet <C > =
5098
+ public fun <C > SingleColumn <* >.colsOf (
5099
+ type : KType ,
5100
+ filter : (DataColumn <C >) -> Boolean = { true },
5101
+ ): TransformableColumnSet <C > =
5057
5102
colsInternal { it.isSubtypeOf(type) && filter(it.cast()) } as TransformableColumnSet <C >
5058
5103
5059
5104
/* *
0 commit comments