32using System.Collections.Generic;
43 List<int> g1 = groups1.
groups;
44 List<int> g2 = groups2.
groups;
47 while (index1 < g1.Count && index2 < g2.Count)
49 if (g1[index1] == g2[index2])
53 else if (g1[index1] < g2[index2])
73 this.groups =
new List<int>(copy.
groups);
81 get {
return groups.Count; }
83 bool ICollection<int>.IsReadOnly
93 public bool Add(
int item)
95 for (
int index = 0; index <
groups.Count; ++index)
103 groups.Insert(index, item);
117 if (array ==
null) {
throw new ArgumentNullException(
"collection"); }
119 List<int> newGroups =
new List<int>(
groups.Count + array.Length);
125 while ((newIndex < array.Length) && (oldIndex <
groups.Count))
127 if (array[newIndex] ==
groups[oldIndex])
131 else if (array[newIndex] >
groups[oldIndex])
133 newGroups.Add(
groups[oldIndex]);
139 newGroups.Add(array[newIndex]);
145 for (; newIndex < array.Length; ++newIndex)
147 if (index == 0 || newGroups[index - 1] != array[newIndex])
149 newGroups.Add(array[newIndex]);
154 for (; oldIndex <
groups.Count; ++oldIndex)
156 if (index == 0 || newGroups[index - 1] !=
groups[oldIndex])
158 newGroups.Add(
groups[oldIndex]);
162 this.groups = newGroups;
172 return groups.BinarySearch(item) >= 0;
181 if (array ==
null) {
throw new ArgumentNullException(
"collection"); }
186 while (index1 <
groups.Count && index2 < array.Length)
188 if (
groups[index1] == array[index2])
194 else if (
groups[index1] < array[index2])
212 int index =
groups.BinarySearch(item);
213 if (index < 0) {
return false; }
224 if (array ==
null) {
throw new ArgumentNullException(
"collection"); }
227 return groups.RemoveAll(delegate(
int value)
229 while (index < array.Length)
231 if (value == array[index])
236 else if (value > array[index])
249 void ICollection<int>.Add(
int item)
260 public void CopyTo(
int[] array,
int arrayIndex)
262 groups.CopyTo(array, arrayIndex);
266 return groups.GetEnumerator();
268 System.Collections.IEnumerator
System.Collections.IEnumerable.GetEnumerator()
270 return GetEnumerator();
A collection that stores ints that represent groups
bool Contains(int item)
returns true if the ignorer is part of the group.
int RemoveRange(int[] array)
Trys to remove the ignorer from a range of groups.
int ContainsRange(int[] array)
returns the number of groups in the array it is part of.
IEnumerator< int > GetEnumerator()
void Clear()
removes the ignorer from all groups.
void CopyTo(int[] array, int arrayIndex)
bool Add(int item)
Trys to add a group.
bool Remove(int item)
Trys to remove the ignorer from a group.
GroupCollection(GroupCollection copy)
int Count
Gets the number of collison Groups the ignorer is part of.
int AddRange(int[] array)
adds an array of group ids.
static bool Intersect(GroupCollection groups1, GroupCollection groups2)