Made addAll() more efficient if it is called with another ArrayIntSet as
its argument. git-svn-id: https://samskivert.googlecode.com/svn/trunk@749 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: ArrayIntSet.java,v 1.7 2002/05/16 22:15:08 mdb Exp $
|
// $Id: ArrayIntSet.java,v 1.8 2002/05/16 22:42:15 mdb Exp $
|
||||||
//
|
//
|
||||||
// samskivert library - useful routines for java programs
|
// samskivert library - useful routines for java programs
|
||||||
// Copyright (C) 2001 Michael Bayne
|
// Copyright (C) 2001 Michael Bayne
|
||||||
@@ -226,9 +226,17 @@ public class ArrayIntSet extends AbstractSet
|
|||||||
public boolean addAll (Collection c)
|
public boolean addAll (Collection c)
|
||||||
{
|
{
|
||||||
boolean modified = false;
|
boolean modified = false;
|
||||||
Iterator iter = c.iterator();
|
if (c instanceof ArrayIntSet) {
|
||||||
while (iter.hasNext()) {
|
ArrayIntSet other = (ArrayIntSet)c;
|
||||||
modified = (add(iter.next()) || modified);
|
for (int ii = 0; ii < other._size; ii++) {
|
||||||
|
modified = (add(other._values[ii]) || modified);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
Iterator iter = c.iterator();
|
||||||
|
while (iter.hasNext()) {
|
||||||
|
modified = (add(iter.next()) || modified);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return modified;
|
return modified;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user