Java Utililty Methods Collection Remove

List of utility methods to do Collection Remove

  1. HOME
  2. Java
  3. C
  4. Collection Remove

Description

The list of methods to do Collection Remove are organized into topic(s).

Method

List getItemsStartingWith(Collection items, String prefix, boolean removePrefix)
get Items Starting With
List<String> rtn = new ArrayList<String>();
for (String s : items) {
 if (s.startsWith(prefix)) {
 if (removePrefix) {
 s = s.substring(prefix.length());
 rtn.add(s);
return rtn;
Collection getRemovedItems(Collection oldValues, Collection newValues)
get Removed Items
return getAddedItems(newValues, oldValues);
Collection minus(Collection primaryCollection, Collection toBeRemovedCollection, Collection target)
Return a new Collection containing the elements of Collection a minus elements of Collection b
target.clear();
for (T elem : primaryCollection) {
 if (!toBeRemovedCollection.contains(elem)) {
 target.add(elem);
return target;
void remove(Collection c, Object o)
remove
c.remove(o);
boolean remove(Collection collection, Object object)
remove
boolean removed = false;
Iterator it = collection.iterator();
while (it.hasNext()) {
 Object o = it.next();
 if (o.equals(object)) {
 removed = true;
 it.remove();
 break;
...
Collection remove(Collection p_collection, int p_index, int p_numberOfObjects)
Removes the element at the specified position in the collection.
if (p_collection == null) {
 return null;
List returnList = new ArrayList(p_collection.size() - p_numberOfObjects);
Iterator it = p_collection.iterator();
for (int i = 0; it.hasNext(); i++) {
 if (i < p_index || i >= p_index + p_numberOfObjects) {
 returnList.add(it.next());
...
boolean remove(Collection col, T value)
remove
if (col == null) {
 return false;
return col.remove(value);
List remove(Collection collection, final int count)
Removes the specified number of elements from the collection, returns them as a list.
List<T> list = new ArrayList<T>();
while (list.size() < count && collection.size() > 0) {
 T value = collection.iterator().next();
 list.add(value);
 collection.remove(value);
return list;
void remove(Collection collection, T... items)
Removes items from collection
for (T t : items) {
 collection.remove(t);
boolean remove(final Collection c, final Object elem)
remove
return (c != null) && c.remove(elem);


AltStyle によって変換されたページ (->オリジナル) /