Skip to content

Commit da2d0c7

Browse files
authored
Added docs and clarifications to functional typealiases
1 parent 65687b4 commit da2d0c7

File tree

1 file changed

+107
-9
lines changed
  • core/src/main/kotlin/org/jetbrains/kotlinx/dataframe

1 file changed

+107
-9
lines changed

core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/aliases.kt

Lines changed: 107 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,130 @@ import org.jetbrains.kotlinx.dataframe.columns.ColumnSet
88
import org.jetbrains.kotlinx.dataframe.columns.ColumnWithPath
99
import org.jetbrains.kotlinx.dataframe.columns.SingleColumn
1010

11-
public typealias Predicate<T> = (T) -> Boolean
12-
13-
public typealias Selector<T, R> = T.(T) -> R
11+
/**
12+
* [Predicate] is used to reach a [Boolean] result using the given instance of `T` as `it`.
13+
*
14+
* Shorthand for:
15+
* ```kotlin
16+
* (it: T) -> Boolean
17+
* ```
18+
*/
19+
public typealias Predicate<T> = (it: T) -> Boolean
20+
21+
/**
22+
* [Selector] is used to express or select any instance of `R` using the given instance of `T` as `this` and `it`.
23+
*
24+
* Shorthand for:
25+
* ```kotlin
26+
* T.(it: T) -> R
27+
* ```
28+
*/
29+
public typealias Selector<T, R> = T.(it: T) -> R
1430

1531
// region selectors
1632

33+
/**
34+
* [DataFrameExpression] is used to express or select any instance of `R` using the given instance of [DataFrame]`<T>`
35+
* as `this` and `it`.
36+
*
37+
* Shorthand for:
38+
* ```kotlin
39+
* DataFrame<T>.(it: DataFrame<T>) -> R
40+
* ```
41+
*/
1742
public typealias DataFrameExpression<T, R> = Selector<DataFrame<T>, R>
1843

44+
/**
45+
* [RowExpression] is used to express or select any instance of `R` using the given instance of [DataRow]`<T>` as
46+
* `this` and `it`.
47+
*
48+
* Shorthand for:
49+
* ```kotlin
50+
* DataRow<T>.(it: DataRow<T>) -> R
51+
* ```
52+
*/
1953
public typealias RowExpression<T, R> = Selector<DataRow<T>, R>
2054

21-
public typealias RowValueExpression<T, C, R> = DataRow<T>.(C) -> R
22-
23-
public typealias RowColumnExpression<T, C, R> = (DataRow<T>, DataColumn<C>) -> R
24-
55+
/**
56+
* [RowValueExpression] is used to express or select any instance of `R` using the given value `it: C` and the given
57+
* instance of [DataRow]`<T>` as `this`.
58+
*
59+
* Shorthand for:
60+
* ```kotlin
61+
* DataRow<T>.(it: C) -> R
62+
* ```
63+
*/
64+
public typealias RowValueExpression<T, C, R> = DataRow<T>.(it: C) -> R
65+
66+
/**
67+
* [RowColumnExpression] is used to express or select any instance of `R` using the given instances of
68+
* [DataRow]`<T>` as `row` and [DataColumn]`<C>` as `col`.
69+
*
70+
* Shorthand for:
71+
* ```kotlin
72+
* (row: DataRow<T>, col: DataColumn<C>) -> R
73+
* ```
74+
*/
75+
public typealias RowColumnExpression<T, C, R> = (row: DataRow<T>, col: DataColumn<C>) -> R
76+
77+
/**
78+
* [ColumnSelector] is used to express or select a single column, represented by [SingleColumn]`<C>`, using the
79+
* context of [ColumnsSelectionDsl]`<T>` as `this` and `it`.
80+
*
81+
* Shorthand for:
82+
* ```kotlin
83+
* ColumnsSelectionDsl<T>.(it: ColumnsSelectionDsl<T>) -> SingleColumn<C>
84+
* ```
85+
*/
2586
public typealias ColumnSelector<T, C> = Selector<ColumnsSelectionDsl<T>, SingleColumn<C>>
2687

88+
/**
89+
* [ColumnsSelector] is used to express or select multiple columns, represented by [ColumnSet]`<C>`, using the
90+
* context of [ColumnsSelectionDsl]`<T>` as `this` and `it`.
91+
*
92+
* Shorthand for:
93+
* ```kotlin
94+
* ColumnsSelectionDsl<T>.(it: ColumnsSelectionDsl<T>) -> ColumnSet<C>
95+
* ```
96+
*/
2797
public typealias ColumnsSelector<T, C> = Selector<ColumnsSelectionDsl<T>, ColumnSet<C>>
2898

2999
// endregion
30100

31101
// region filters
32102

103+
/**
104+
* [RowFilter] is used to filter or find rows using the given instance of [DataRow]`<T>` as `this` and `it`.
105+
* Return `true` if the row should be included in the result.
106+
*
107+
* Shorthand for:
108+
* ```kotlin
109+
* DataRow<T>.(it: DataRow<T>) -> Boolean
110+
* ```
111+
*/
33112
public typealias RowFilter<T> = RowExpression<T, Boolean>
34113

35-
public typealias ColumnFilter<T> = (ColumnWithPath<T>) -> Boolean
36-
114+
/**
115+
* [ColumnFilter] is used to filter or find columns using the given instance of [ColumnWithPath]`<T>` as `it`.
116+
* Return `true` if the column should be included in the result.
117+
*
118+
* Shorthand for:
119+
* ```kotlin
120+
* (it: ColumnWithPath<T>) -> Boolean
121+
* ```
122+
*/
123+
public typealias ColumnFilter<T> = Predicate<ColumnWithPath<T>>
124+
125+
/**
126+
* [RowValueFilter] is used to filter or find rows using the given value of `it: C` and the given instance of
127+
* [DataRow]`<T>` as `this`.
128+
* Return `true` if the row should be included in the result.
129+
*
130+
* Shorthand for:
131+
* ```kotlin
132+
* DataRow<T>.(it: C) -> Boolean
133+
* ```
134+
*/
37135
public typealias RowValueFilter<T, C> = RowValueExpression<T, C, Boolean>
38136

39137
// endregion

0 commit comments

Comments
 (0)