@@ -259,13 +259,13 @@ public interface ColumnsSelectionDsl<out T> : ColumnSelectionDsl<T>, SingleColum
259
259
260
260
/* *
261
261
* ## First
262
- * Returns the first column in this [ColumnSet] that adheres to the given [condition\].
262
+ * Returns the first column in this [ColumnSet] or [ColumnGroup] that adheres to the given [condition\].
263
263
*
264
264
* For example:
265
265
*
266
266
* {@includeArg [Examples]}
267
267
*
268
- * @param [condition\] The [ColumnFilter] condition that the column must adhere to.
268
+ * @param [condition\] The optional [ColumnFilter] condition that the column must adhere to.
269
269
* @return A [SingleColumn] containing the first column that adheres to the given [condition\].
270
270
* @see [last\]
271
271
*/
@@ -277,61 +277,95 @@ public interface ColumnsSelectionDsl<out T> : ColumnSelectionDsl<T>, SingleColum
277
277
278
278
/* *
279
279
* ## First
280
- * Returns the first column in this [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] that adheres to the given [condition].
280
+ * Returns the first column in this [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] or [ColumnGroup][org.jetbrains.kotlinx.dataframe.columns.ColumnGroup] that adheres to the given [condition].
281
+ *
282
+ * For example:
283
+ *
284
+ * `df.`[select][select]` { `[colsOf][colsOf]`<`[String][String]`>().`[first][first]` { it.`[name][ColumnReference.name]`().`[startsWith][String.startsWith]`("year") } }`
285
+ *
286
+ * `df.`[select][select]` { `[colsOf][colsOf]`<`[Int][Int]`>().`[first][first]`() }`
287
+ *
288
+ * @param [condition] The optional [ColumnFilter][org.jetbrains.kotlinx.dataframe.ColumnFilter] condition that the column must adhere to.
289
+ * @return A [SingleColumn][org.jetbrains.kotlinx.dataframe.columns.SingleColumn] containing the first column that adheres to the given [condition].
290
+ * @see [last]
291
+ */
292
+ public fun <C > ColumnSet<C>.first (condition : ColumnFilter <C > = { true }): SingleColumn <C > =
293
+ transform { listOf (it.first(condition)) }.single()
294
+
295
+ /* *
296
+ * ## First
297
+ * Returns the first column in this [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] or [ColumnGroup][org.jetbrains.kotlinx.dataframe.columns.ColumnGroup] that adheres to the given [condition].
281
298
*
282
299
* For example:
283
300
*
284
301
* `df.`[select][select]` { `[first][first]` { it.`[name][ColumnReference.name]`().`[startsWith][String.startsWith]`("year") } }`
285
302
*
303
+ * `df.`[select][select]` { `[first][first]`() }`
304
+ *
305
+ * @param [condition] The optional [ColumnFilter][org.jetbrains.kotlinx.dataframe.ColumnFilter] condition that the column must adhere to.
306
+ * @return A [SingleColumn][org.jetbrains.kotlinx.dataframe.columns.SingleColumn] containing the first column that adheres to the given [condition].
307
+ * @see [last]
308
+ */
309
+ public fun first (condition : ColumnFilter <* > = { true }): SingleColumn <* > =
310
+ all().first(condition)
311
+
312
+ /* *
313
+ * ## First
314
+ * Returns the first column in this [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] or [ColumnGroup][org.jetbrains.kotlinx.dataframe.columns.ColumnGroup] that adheres to the given [condition].
315
+ *
316
+ * For example:
317
+ *
318
+ * `df.`[select][select]` { myColumnGroup.`[first][first]` { it.`[name][ColumnReference.name]`().`[startsWith][String.startsWith]`("year") } }`
319
+ *
286
320
* `df.`[select][select]` { myColumnGroup.`[first][first]`() }`
287
321
*
288
- * @param [condition] The [ColumnFilter][org.jetbrains.kotlinx.dataframe.ColumnFilter] condition that the column must adhere to.
322
+ * @param [condition] The optional [ColumnFilter][org.jetbrains.kotlinx.dataframe.ColumnFilter] condition that the column must adhere to.
289
323
* @return A [SingleColumn][org.jetbrains.kotlinx.dataframe.columns.SingleColumn] containing the first column that adheres to the given [condition].
290
324
* @see [last]
291
325
*/
292
- public fun < C > ColumnSet<C> .first (condition : ColumnFilter <C > = { true }): SingleColumn <C > =
293
- children { condition(it.cast()) }[ 0 ].cast( )
326
+ public fun ColumnGroupReference .first (condition : ColumnFilter <* > = { true }): SingleColumn <* > =
327
+ all().first(condition )
294
328
295
329
/* *
296
330
* ## First
297
- * Returns the first column in this [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] that adheres to the given [condition].
331
+ * Returns the first column in this [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] or [ColumnGroup][org.jetbrains.kotlinx.dataframe.columns.ColumnGroup] that adheres to the given [condition].
298
332
*
299
333
* For example:
300
334
*
301
335
* `df.`[select][select]` { "myColumnGroup".`[first][first]` { it.`[name][ColumnReference.name]`().`[startsWith][String.startsWith]`("year") } }`
302
336
*
303
- * @param [condition] The [ColumnFilter][org.jetbrains.kotlinx.dataframe.ColumnFilter] condition that the column must adhere to.
337
+ * @param [condition] The optional [ColumnFilter][org.jetbrains.kotlinx.dataframe.ColumnFilter] condition that the column must adhere to.
304
338
* @return A [SingleColumn][org.jetbrains.kotlinx.dataframe.columns.SingleColumn] containing the first column that adheres to the given [condition].
305
339
* @see [last]
306
340
*/
307
341
public fun String.first (condition : ColumnFilter <* > = { true }): SingleColumn <* > =
308
- toColumnAccessor( ).first(condition)
342
+ getColumnGroup( this ).first(condition)
309
343
310
344
/* *
311
345
* ## First
312
- * Returns the first column in this [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] that adheres to the given [condition].
346
+ * Returns the first column in this [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] or [ColumnGroup][org.jetbrains.kotlinx.dataframe.columns.ColumnGroup] that adheres to the given [condition].
313
347
*
314
348
* For example:
315
349
*
316
350
* `df.`[select][select]` { Type::myColumnGroup.`[first][first]` { it.`[name][ColumnReference.name]`().`[startsWith][String.startsWith]`("year") } }`
317
351
*
318
- * @param [condition] The [ColumnFilter][org.jetbrains.kotlinx.dataframe.ColumnFilter] condition that the column must adhere to.
352
+ * @param [condition] The optional [ColumnFilter][org.jetbrains.kotlinx.dataframe.ColumnFilter] condition that the column must adhere to.
319
353
* @return A [SingleColumn][org.jetbrains.kotlinx.dataframe.columns.SingleColumn] containing the first column that adheres to the given [condition].
320
354
* @see [last]
321
355
*/
322
- public fun < C > KProperty<C >.first (condition : ColumnFilter <C >): SingleColumn <* > =
323
- toColumnAccessor( ).first(condition)
356
+ public fun KProperty <* >.first (condition : ColumnFilter <* >): SingleColumn <* > =
357
+ getColumnGroup( this ).first(condition)
324
358
325
359
326
360
/* *
327
361
* ## Last
328
- * Returns the last column in this [ColumnSet] that adheres to the given [condition\].
362
+ * Returns the last column in this [ColumnSet] or [ColumnGroup] that adheres to the given [condition\].
329
363
*
330
364
* For example:
331
365
*
332
366
* {@includeArg [Examples]}
333
367
*
334
- * @param [condition\] The [ColumnFilter] condition that the column must adhere to.
368
+ * @param [condition\] The optional [ColumnFilter] condition that the column must adhere to.
335
369
* @return A [SingleColumn] containing the last column that adheres to the given [condition\].
336
370
* @see [first\]
337
371
*/
@@ -343,53 +377,84 @@ public interface ColumnsSelectionDsl<out T> : ColumnSelectionDsl<T>, SingleColum
343
377
344
378
/* *
345
379
* ## Last
346
- * Returns the last column in this [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] that adheres to the given [condition].
380
+ * Returns the last column in this [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] or [ColumnGroup][org.jetbrains.kotlinx.dataframe.columns.ColumnGroup] that adheres to the given [condition].
347
381
*
348
382
* For example:
349
383
*
350
- * `df.`[select][select]` { `[last][last]` { it.`[name][ColumnReference.name]`().`[startsWith][String.startsWith]`("year") } }`
384
+ * `df.`[select][select]` { `[colsOf][colsOf]`<`[String][String]`>().`[ last][last]` { it.`[name][ColumnReference.name]`().`[startsWith][String.startsWith]`("year") } }`
351
385
*
352
- * `df.`[select][select]` { myColumnGroup .`[first][last]`() }`
386
+ * `df.`[select][select]` { `[colsOf][colsOf]`<`[Int][Int]`>() .`[first][last]`() }`
353
387
*
354
- * @param [condition] The [ColumnFilter][org.jetbrains.kotlinx.dataframe.ColumnFilter] condition that the column must adhere to.
388
+ * @param [condition] The optional [ColumnFilter][org.jetbrains.kotlinx.dataframe.ColumnFilter] condition that the column must adhere to.
355
389
* @return A [SingleColumn][org.jetbrains.kotlinx.dataframe.columns.SingleColumn] containing the last column that adheres to the given [condition].
356
390
* @see [first]
357
391
*/
358
392
public fun <C > ColumnSet<C>.last (condition : ColumnFilter <C > = { true }): SingleColumn <C > =
359
- children { condition(it.cast()) }
360
- .transform { listOf (it.last()) }
361
- .single()
362
- .cast()
393
+ transform { listOf (it.last(condition)) }.single()
394
+
395
+ /* *
396
+ * ## Last
397
+ * Returns the last column in this [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] or [ColumnGroup][org.jetbrains.kotlinx.dataframe.columns.ColumnGroup] that adheres to the given [condition].
398
+ *
399
+ * For example:
400
+ *
401
+ * `df.`[select][select]` { `[last][last]` { it.`[name][ColumnReference.name]`().`[startsWith][String.startsWith]`("year") } }`
402
+ *
403
+ * `df.`[select][select]` { `[first][last]`() }`
404
+ *
405
+ * @param [condition] The optional [ColumnFilter][org.jetbrains.kotlinx.dataframe.ColumnFilter] condition that the column must adhere to.
406
+ * @return A [SingleColumn][org.jetbrains.kotlinx.dataframe.columns.SingleColumn] containing the last column that adheres to the given [condition].
407
+ * @see [first]
408
+ */
409
+ public fun last (condition : ColumnFilter <* > = { true }): SingleColumn <* > =
410
+ all().last(condition)
411
+
412
+ /* *
413
+ * ## Last
414
+ * Returns the last column in this [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] or [ColumnGroup][org.jetbrains.kotlinx.dataframe.columns.ColumnGroup] that adheres to the given [condition].
415
+ *
416
+ * For example:
417
+ *
418
+ * `df.`[select][select]` { myColumnGroup.`[last][last]` { it.`[name][ColumnReference.name]`().`[startsWith][String.startsWith]`("year") } }`
419
+ *
420
+ * `df.`[select][select]` { myColumnGroup.`[last][last]`() }`
421
+ *
422
+ * @param [condition] The optional [ColumnFilter][org.jetbrains.kotlinx.dataframe.ColumnFilter] condition that the column must adhere to.
423
+ * @return A [SingleColumn][org.jetbrains.kotlinx.dataframe.columns.SingleColumn] containing the last column that adheres to the given [condition].
424
+ * @see [first]
425
+ */
426
+ public fun ColumnGroupReference.last (condition : ColumnFilter <* > = { true }): SingleColumn <* > =
427
+ all().last(condition)
363
428
364
429
/* *
365
430
* ## Last
366
- * Returns the last column in this [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] that adheres to the given [condition].
431
+ * Returns the last column in this [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] or [ColumnGroup][org.jetbrains.kotlinx.dataframe.columns.ColumnGroup] that adheres to the given [condition].
367
432
*
368
433
* For example:
369
434
*
370
435
* `df.`[select][select]` { "myColumnGroup".`[last][last]` { it.`[name][ColumnReference.name]`().`[startsWith][String.startsWith]`("year") } }`
371
436
*
372
- * @param [condition] The [ColumnFilter][org.jetbrains.kotlinx.dataframe.ColumnFilter] condition that the column must adhere to.
437
+ * @param [condition] The optional [ColumnFilter][org.jetbrains.kotlinx.dataframe.ColumnFilter] condition that the column must adhere to.
373
438
* @return A [SingleColumn][org.jetbrains.kotlinx.dataframe.columns.SingleColumn] containing the last column that adheres to the given [condition].
374
439
* @see [first]
375
440
*/
376
441
public fun String.last (condition : ColumnFilter <* > = { true }): SingleColumn <* > =
377
- toColumnAccessor( ).last(condition)
442
+ getColumnGroup( this ).last(condition)
378
443
379
444
/* *
380
445
* ## Last
381
- * Returns the last column in this [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] that adheres to the given [condition].
446
+ * Returns the last column in this [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] or [ColumnGroup][org.jetbrains.kotlinx.dataframe.columns.ColumnGroup] that adheres to the given [condition].
382
447
*
383
448
* For example:
384
449
*
385
450
* `df.`[select][select]` { Type::myColumnGroup.`[last][last]` { it.`[name][ColumnReference.name]`().`[startsWith][String.startsWith]`("year") } }`
386
451
*
387
- * @param [condition] The [ColumnFilter][org.jetbrains.kotlinx.dataframe.ColumnFilter] condition that the column must adhere to.
452
+ * @param [condition] The optional [ColumnFilter][org.jetbrains.kotlinx.dataframe.ColumnFilter] condition that the column must adhere to.
388
453
* @return A [SingleColumn][org.jetbrains.kotlinx.dataframe.columns.SingleColumn] containing the last column that adheres to the given [condition].
389
454
* @see [first]
390
455
*/
391
- public fun < C > KProperty<C >.last (condition : ColumnFilter <C >): SingleColumn <* > =
392
- toColumnAccessor( ).last(condition)
456
+ public fun KProperty <* >.last (condition : ColumnFilter <* >): SingleColumn <* > =
457
+ getColumnGroup( this ).last(condition)
393
458
394
459
public fun <C > ColumnSet<C>.single (condition : ColumnFilter <C >): SingleColumn <C > =
395
460
transform { listOf (it.single(condition)) }.single()
0 commit comments