/** * Returns an array containing all of the elements in this composite. * * @return an object array of all the elements in the collection */ public Object[] toArray() { final Object[] result = new Object[this.size()]; int i = 0; for (Iterator it = this.iterator(); it.hasNext(); i++) { result[i] = it.next(); } return result; }
/** * Returns an array containing all of the elements in this composite. * * @return an object array of all the elements in the collection */ public Object[] toArray() { final Object[] result = new Object[this.size()]; int i = 0; for (Iterator it = this.iterator(); it.hasNext(); i++) { result[i] = it.next(); } return result; }
/** * Returns an object array, populating the supplied array if possible. * See <code>Collection</code> interface for full details. * * @param array the array to use, populating if possible * @return an array of all the elements in the collection */ public Object[] toArray(Object[] array) { int size = this.size(); Object[] result = null; if (array.length >= size) { result = array; } else { result = (Object[]) Array.newInstance(array.getClass().getComponentType(), size); } int offset = 0; for (int i = 0; i < this.all.length; ++i) { for (Iterator it = this.all[i].iterator(); it.hasNext();) { result[offset++] = it.next(); } } if (result.length > size) { result[size] = null; } return result; }
/** * Returns an object array, populating the supplied array if possible. * See <code>Collection</code> interface for full details. * * @param array the array to use, populating if possible * @return an array of all the elements in the collection */ public Object[] toArray(Object[] array) { int size = this.size(); Object[] result = null; if (array.length >= size) { result = array; } else { result = (Object[]) Array.newInstance(array.getClass().getComponentType(), size); } int offset = 0; for (int i = 0; i < this.all.length; ++i) { for (Iterator it = this.all[i].iterator(); it.hasNext();) { result[offset++] = it.next(); } } if (result.length > size) { result[size] = null; } return result; }
public void testSize() { setUpTest(); HashSet set = new HashSet(); set.add("a"); set.add("b"); c.addComposited(set); assertEquals(set.size(), c.size()); }
public void testMultipleCollectionsSize() { setUpTest(); HashSet set = new HashSet(); set.add("a"); set.add("b"); c.addComposited(set); HashSet other = new HashSet(); other.add("c"); c.addComposited(other); assertEquals(set.size() + other.size(), c.size()); }
public void testAddAllToCollection() { setUpTest(); one.add("1"); two.add("2"); c.addComposited(one, two); Collection toCollection = new HashSet(); toCollection.addAll(c); assertTrue(toCollection.containsAll(c)); assertEquals(c.size(), toCollection.size()); }
public void testToCollection() { setUpTest(); one.add("1"); two.add("2"); c.addComposited(one, two); Collection foo = c.toCollection(); assertTrue(foo.containsAll(c)); assertEquals(c.size(), foo.size()); one.add("3"); assertTrue(!foo.containsAll(c)); }
public void testRemoveComposited() { setUpMutatorTest(); one.add("1"); two.add("2"); two.add("1"); c.addComposited(one, two); c.removeComposited(one); assertTrue(c.contains("1")); assertEquals(c.size(), 2); } }
/** * Returns an array containing all of the elements in this composite. * * @return an object array of all the elements in the collection */ public Object[] toArray() { final Object[] result = new Object[this.size()]; int i = 0; for (Iterator it = this.iterator(); it.hasNext(); i++) { result[i] = it.next(); } return result; }
/** * Returns an array containing all of the elements in this composite. * * @return an object array of all the elements in the collection */ public Object[] toArray() { final Object[] result = new Object[this.size()]; int i = 0; for (Iterator it = this.iterator(); it.hasNext(); i++) { result[i] = it.next(); } return result; }
/** * Returns an array containing all of the elements in this composite. * * @return an object array of all the elements in the collection */ public Object[] toArray() { final Object[] result = new Object[this.size()]; int i = 0; for (Iterator it = this.iterator(); it.hasNext(); i++) { result[i] = it.next(); } return result; }
/** * Returns an array containing all of the elements in this composite. * * @return an object array of all the elements in the collection */ public Object[] toArray() { final Object[] result = new Object[this.size()]; int i = 0; for (Iterator it = this.iterator(); it.hasNext(); i++) { result[i] = it.next(); } return result; }
/** * Returns an array containing all of the elements in this composite. * * @return an object array of all the elements in the collection */ public Object[] toArray() { final Object[] result = new Object[this.size()]; int i = 0; for (Iterator it = this.iterator(); it.hasNext(); i++) { result[i] = it.next(); } return result; }
/** * Returns an object array, populating the supplied array if possible. * See <code>Collection</code> interface for full details. * * @param array the array to use, populating if possible * @return an array of all the elements in the collection */ public Object[] toArray(Object[] array) { int size = this.size(); Object[] result = null; if (array.length >= size) { result = array; } else { result = (Object[]) Array.newInstance(array.getClass().getComponentType(), size); } int offset = 0; for (int i = 0; i < this.all.length; ++i) { for (Iterator it = this.all[i].iterator(); it.hasNext();) { result[offset++] = it.next(); } } if (result.length > size) { result[size] = null; } return result; }
/** * Returns an object array, populating the supplied array if possible. * See <code>Collection</code> interface for full details. * * @param array the array to use, populating if possible * @return an array of all the elements in the collection */ public Object[] toArray(Object[] array) { int size = this.size(); Object[] result = null; if (array.length >= size) { result = array; } else { result = (Object[]) Array.newInstance(array.getClass().getComponentType(), size); } int offset = 0; for (int i = 0; i < this.all.length; ++i) { for (Iterator it = this.all[i].iterator(); it.hasNext();) { result[offset++] = it.next(); } } if (result.length > size) { result[size] = null; } return result; }
/** * Returns an object array, populating the supplied array if possible. * See <code>Collection</code> interface for full details. * * @param array the array to use, populating if possible * @return an array of all the elements in the collection */ public Object[] toArray(Object[] array) { int size = this.size(); Object[] result = null; if (array.length >= size) { result = array; } else { result = (Object[]) Array.newInstance(array.getClass().getComponentType(), size); } int offset = 0; for (int i = 0; i < this.all.length; ++i) { for (Iterator it = this.all[i].iterator(); it.hasNext();) { result[offset++] = it.next(); } } if (result.length > size) { result[size] = null; } return result; }
/** * Returns an object array, populating the supplied array if possible. * See <code>Collection</code> interface for full details. * * @param array the array to use, populating if possible * @return an array of all the elements in the collection */ public Object[] toArray(Object[] array) { int size = this.size(); Object[] result = null; if (array.length >= size) { result = array; } else { result = (Object[]) Array.newInstance(array.getClass().getComponentType(), size); } int offset = 0; for (int i = 0; i < this.all.length; ++i) { for (Iterator it = this.all[i].iterator(); it.hasNext();) { result[offset++] = it.next(); } } if (result.length > size) { result[size] = null; } return result; }
/** * Returns an object array, populating the supplied array if possible. * See <code>Collection</code> interface for full details. * * @param array the array to use, populating if possible * @return an array of all the elements in the collection */ public Object[] toArray(Object[] array) { int size = this.size(); Object[] result = null; if (array.length >= size) { result = array; } else { result = (Object[]) Array.newInstance(array.getClass().getComponentType(), size); } int offset = 0; for (int i = 0; i < this.all.length; ++i) { for (Iterator it = this.all[i].iterator(); it.hasNext();) { result[offset++] = it.next(); } } if (result.length > size) { result[size] = null; } return result; }