-
-
Notifications
You must be signed in to change notification settings - Fork 30
/
k_collection.dart
58 lines (48 loc) · 1.46 KB
/
k_collection.dart
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
import 'dart:math' as math show Random;
import 'package:dart_kollection/dart_kollection.dart';
/**
* A generic collection of elements. Methods in this interface support only read-only access to the collection;
* read/write access is supported through the [KMutableCollection] interface.
* @param E the type of elements contained in the collection. The collection is covariant on its element type.
*/
abstract class KCollection<T> implements KIterable<T>, KCollectionExtension<T> {
// Query Operations
/**
* Returns the size of the collection.
*/
int get size;
/**
* Returns `true` if the collection is empty (contains no elements), `false` otherwise.
*/
bool isEmpty();
/**
* Checks if the specified element is contained in this collection.
*/
@override
bool contains(T element);
@override
KIterator<T> iterator();
// Bulk Operations
/**
* Checks if all elements in the specified collection are contained in this collection.
*/
bool containsAll(KCollection<T> elements);
@override
KList<T> drop(int n);
}
abstract class KCollectionExtension<T> {
/**
* Returns `true` if the collection is not empty.
*/
bool isNotEmpty();
/**
* Returns a random element from this collection.
*
* @throws NoSuchElementException if this collection is empty.
*/
T random([math.Random random]);
/**
* Returns a [KMutableList] filled with all elements of this collection.
*/
KMutableList<T> toMutableList();
}