IKVM11  11
Java SE 11 Virtual Machine for .NET
Loading...
Searching...
No Matches
SetWrapper.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using System.Linq;
4
5namespace java.util
6{
7
8 class SetWrapper<T> : CollectionWrapper<T>, ISet<T>
9 {
10
11 readonly Set _set;
12
18 public SetWrapper(Set set) :
19 base(set)
20 {
21 _set = set ?? throw new ArgumentNullException(nameof(set));
22 }
23
25 public void ExceptWith(IEnumerable<T> other)
26 {
27 if (other is T[] array)
28 _set.removeAll(Arrays.asList(array));
29 else if (other is Collection c)
30 _set.removeAll(c);
31 else if (other is CollectionWrapper<T> wrapper)
32 _set.removeAll(wrapper._collection);
33 else
34 _set.removeAll(Arrays.asList(other.ToArray()));
35 }
36
38 public void IntersectWith(IEnumerable<T> other)
39 {
40 if (other is T[] array)
41 _set.retainAll(Arrays.asList(array));
42 else if (other is Collection c)
43 _set.retainAll(c);
44 else if (other is CollectionWrapper<T> wrapper)
45 _set.retainAll(wrapper._collection);
46 else
47 _set.retainAll(Arrays.asList(other.ToArray()));
48 }
49
51 public bool IsProperSubsetOf(IEnumerable<T> other)
52 {
53 throw new NotImplementedException();
54 }
55
57 public bool IsProperSupersetOf(IEnumerable<T> other)
58 {
59 throw new NotImplementedException();
60 }
61
63 public bool IsSubsetOf(IEnumerable<T> other)
64 {
65 throw new NotImplementedException();
66 }
67
69 public bool IsSupersetOf(IEnumerable<T> other)
70 {
71 throw new NotImplementedException();
72 }
73
75 public bool Overlaps(IEnumerable<T> other)
76 {
77 throw new NotImplementedException();
78 }
79
81 public bool SetEquals(IEnumerable<T> other)
82 {
83 throw new NotImplementedException();
84 }
85
87 public void SymmetricExceptWith(IEnumerable<T> other)
88 {
89 throw new NotImplementedException();
90 }
91
93 public void UnionWith(IEnumerable<T> other)
94 {
95 if (other is T[] array)
96 _set.addAll(Arrays.asList(array));
97 else if (other is Collection c)
98 _set.addAll(c);
99 else if (other is CollectionWrapper<T> wrapper)
100 _set.addAll(wrapper._collection);
101 else
102 _set.addAll(Arrays.asList(other.ToArray()));
103 }
104
106 bool ISet<T>.Add(T item)
107 {
108 return _set.add(item);
109 }
110
111 }
112
113}
void UnionWith(IEnumerable< T > other)
Definition SetWrapper.cs:93
bool IsSubsetOf(IEnumerable< T > other)
Definition SetWrapper.cs:63
void ExceptWith(IEnumerable< T > other)
Definition SetWrapper.cs:25
bool Overlaps(IEnumerable< T > other)
Definition SetWrapper.cs:75
bool SetEquals(IEnumerable< T > other)
Definition SetWrapper.cs:81
void SymmetricExceptWith(IEnumerable< T > other)
Definition SetWrapper.cs:87
bool IsSupersetOf(IEnumerable< T > other)
Definition SetWrapper.cs:69
void IntersectWith(IEnumerable< T > other)
Definition SetWrapper.cs:38
SetWrapper(Set set)
Initializes a new instance.
Definition SetWrapper.cs:18
bool IsProperSupersetOf(IEnumerable< T > other)
Definition SetWrapper.cs:57
bool IsProperSubsetOf(IEnumerable< T > other)
Definition SetWrapper.cs:51