9 package javolution.util.internal.collection;
11 import java.util.Collection;
12 import java.util.Iterator;
13 import java.util.List;
43 public abstract boolean add(E element);
46 public boolean addAll(Collection<? extends E> c) {
47 boolean changed =
false;
48 Iterator<? extends E> it = c.iterator();
49 while (it.hasNext()) {
50 if (
add(it.next())) changed =
true;
57 Iterator<? extends E> it =
iterator();
58 while (it.hasNext()) {
64 @SuppressWarnings(
"unchecked")
73 }
catch (CloneNotSupportedException e) {
74 throw new Error(
"Should not happen since target is cloneable");
82 @SuppressWarnings(
"unchecked")
84 Iterator<? extends E> it =
iterator();
86 while (it.hasNext()) {
87 if (cmp.
areEqual(obj, it.next()))
return true;
100 @SuppressWarnings(
"unchecked")
104 if (
this == o)
return true;
112 if (
this instanceof Set) {
113 if (!(o instanceof Set))
return false;
114 Set<E>
set = (Set<E>) o;
116 }
else if (
this instanceof List) {
117 if (!(o instanceof List))
return false;
118 List<E> list = (List<E>) o;
119 if (
size() != list.size())
return false;
122 Iterator<E> it2 = list.iterator();
123 while (it1.hasNext()) {
124 if (!it2.hasNext())
return false;
125 if (!cmp.
areEqual(it1.next(), it2.next()))
return false;
127 if (it2.hasNext())
return false;
140 if (
this instanceof Set) {
141 while (it.hasNext()) {
144 }
else if (
this instanceof List) {
145 while (it.hasNext()) {
146 hash += 31 * hash + cmp.
hashCodeOf(it.next());
149 hash = super.hashCode();
167 target.perform(action, view);
172 @SuppressWarnings(
"unchecked")
174 Iterator<? extends E> it =
iterator();
176 while (it.hasNext()) {
187 boolean changed =
false;
188 Iterator<? extends E> it =
iterator();
189 while (it.hasNext()) {
190 if (c.contains(it.next())) {
200 boolean changed =
false;
201 Iterator<? extends E> it =
iterator();
202 while (it.hasNext()) {
203 if (!c.contains(it.next())) {
214 Iterator<? extends E> it =
iterator();
215 while (it.hasNext()) {
222 @SuppressWarnings(
"unchecked")
228 for (
int i = 0; i < subTargets.length; i++) {
230 copy.
target = subTargets[i];
248 @SuppressWarnings(
"unchecked")
251 final T[] result = (
size <= a.length) ? a
252 : (T[]) java.lang.reflect.Array.newInstance(a.getClass()
253 .getComponentType(),
size);
256 while (it.hasNext()) {
257 result[i++] = (T) it.next();
259 if (result.length >
size) {
270 target.perform(action, view);