IKVM11  11
Java SE 11 Virtual Machine for .NET
Loading...
Searching...
No Matches
CollectionWrapper.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3
4using java.lang;
5
6namespace java.util
7{
8
9 class CollectionWrapper<T> : IterableWrapper<T>, ICollection<T>
10 {
11
12 internal readonly Collection _collection;
13
19 public CollectionWrapper(Collection collection) : base(collection)
20 {
21 _collection = collection ?? throw new ArgumentNullException(nameof(collection));
22 }
23
25 public int Count => _collection.size();
26
28 public bool IsReadOnly => false;
29
31 public void Add(T item) => _collection.add(item);
32
34 public void Clear() => _collection.clear();
35
37 public bool Contains(T item) => _collection.contains(item);
38
40 public void CopyTo(T[] array, int arrayIndex)
41 {
42 foreach (var entry in this)
43 array[arrayIndex++] = entry;
44 }
45
47 public bool Remove(T item) => _collection.remove(item);
48
49 }
50
51}
Wraps an Iterable as a IEnumerable.
CollectionWrapper(Collection collection)
Initializes a new instance.
void CopyTo(T[] array, int arrayIndex)