|
1 | 1 | package com.quickbirdstudios.nonEmptyCollection.list |
2 | 2 |
|
3 | | -operator fun <T> NonEmptyList<T>.plus(value: T): NonEmptyList<T> = NonEmptyList(full + value) |
| 3 | +import kotlin.collections.plus as stdPlus |
4 | 4 |
|
5 | | -operator fun <T> List<T>.plus(value: T): NonEmptyList<T> = NonEmptyList(this as Collection<T> + value) |
| 5 | +operator fun <T> NonEmptyList<T>.plus(value: T): NonEmptyList<T> = full + value |
6 | 6 |
|
7 | | -operator fun <T> NonEmptyList<T>.plus(other: List<T>): NonEmptyList<T> = NonEmptyList(full as Collection<T> + other) |
| 7 | +operator fun <T> List<T>.plus(value: T): NonEmptyList<T> = NonEmptyList(this.stdPlus(value)) |
| 8 | + |
| 9 | +operator fun <T> NonEmptyList<T>.plus(other: Iterable<T>): NonEmptyList<T> = NonEmptyList(full.stdPlus(other)) |
8 | 10 |
|
9 | 11 | operator fun <T> List<T>.plus( |
10 | 12 | other: NonEmptyList<T> |
11 | | -): NonEmptyList<T> = NonEmptyList(this as Collection<T> + other.full) |
| 13 | +): NonEmptyList<T> = NonEmptyList(this.stdPlus(other.full)) |
12 | 14 |
|
13 | 15 | operator fun <T> NonEmptyList<T>.plus( |
14 | 16 | other: NonEmptyList<T> |
15 | | -): NonEmptyList<T> = NonEmptyList(full as Collection<T> + other.full) |
16 | | - |
17 | | -operator fun <T> NonEmptyList<T>.plus( |
18 | | - other: Iterable<T> |
19 | | -): NonEmptyList<T> = this + other.toList() |
| 17 | +): NonEmptyList<T> = full + other |
20 | 18 |
|
21 | 19 | operator fun <T> NonEmptyList<T>.plus( |
22 | 20 | other: Sequence<T> |
23 | | -): NonEmptyList<T> = this + other.toList() |
| 21 | +): NonEmptyList<T> = NonEmptyList( |
| 22 | + ArrayList<T>(full.size).apply { |
| 23 | + addAll(full) |
| 24 | + addAll(other) |
| 25 | + } |
| 26 | +) |
24 | 27 |
|
25 | 28 | operator fun <T> NonEmptyList<T>.plus( |
26 | 29 | other: Array<T> |
27 | | -): NonEmptyList<T> = this + other.toList() |
| 30 | +): NonEmptyList<T> = NonEmptyList( |
| 31 | + ArrayList<T>(full.size + other.size).apply { |
| 32 | + addAll(full) |
| 33 | + addAll(other) |
| 34 | + } |
| 35 | +) |
0 commit comments