Uses the iterator to run through the dao and retain only the items that are in the passed in collection. This
will remove the items from the associated database table as well.

@return Returns true of the collection was changed at all otherwise false.
978217
@Override
	public boolean retainAll(Collection<?> collection) {
		if (dao == null) {
			return false;
		}
		boolean changed = false;
		CloseableIterator<T> iterator = closeableIterator();
		try {
			while (iterator.hasNext()) {
				T data = iterator.next();
				if (!collection.contains(data)) {
					iterator.remove();
					changed = true;
				}
			}
			return changed;
		} finally {
			IOUtils.closeQuietly(iterator);
		}
	}
493290
public boolean removeBusItinerary(BusItinerary itinerary) {
		final int index = this.itineraries.indexOf(itinerary);
		if (index >= 0) {
			return removeBusItinerary(index);
		}
		return false;
	}
362824
public Collection<B> values() {
	return new AbstractCollection<B>() {
	    public int size() { return map.size(); }
	    public Iterator<B> iterator() {
		return 
		    DSUtil.<Map.Entry<A,B>,B>mapIterator
		    (BijMap.this.entrySet().iterator(),
		     new Function<Map.Entry<A,B>,B>() {
			public B f(Map.Entry<A,B> entry) {
			    return entry.getValue();
			}
		    });
	    }
	    public boolean remove(Object b) {
		return BijMap.this.rev().remove(b) != null;
	    }
	    public void clear() {
		BijMap.this.clear();
	    }
	};
    }
940453
private boolean hasNextLazy() {
        try {
            while (true) {
                switch (this.queryState) {
                    case REGULAR:
                        if (this.elements != null) {
                            return true;
                        } else {
                            if (this.queryResult != null) {
                                iterateRegularQueries();
                                this.first = false;
                            }
                            if (this.elements == null) {
                                closePreparedStatement();
                                //try the next distinctQueryStack
                                if (this.distinctQueriesIterator.hasNext()) {
                                    this.currentDistinctQueryStack = this.distinctQueriesIterator.next();
                                    this.subQueryStacks = SchemaTableTree.splitIntoSubStacks(this.currentDistinctQueryStack);
                                    this.currentRootSchemaTableTree.resetColumnAliasMaps();
                                    //if there are duplicates in the stack we can not execute drop steps.
                                    //execute the query as per normal and the proper DropStep will do the rest.
                                    if (this.currentDistinctQueryStack.getLast().isDrop() && !this.currentRootSchemaTableTree.duplicatesInStack(currentDistinctQueryStack)) {
                                        executeDropQuery();
                                    } else {
                                        executeRegularQuery();
                                    }
                                    this.first = true;
                                } else {
                                    //try the next rootSchemaTableTree
                                    if (this.rootSchemaTableTreeIterator.hasNext()) {
                                        this.currentRootSchemaTableTree = this.rootSchemaTableTreeIterator.next();
                                        this.distinctQueriesIterator = this.currentRootSchemaTableTree.constructDistinctQueries().iterator();
                                    } else {
                                        if (this.currentRootSchemaTableTree != null) {
                                            this.currentRootSchemaTableTree.resetColumnAliasMaps();
                                        }
                                        this.queryState = QUERY.OPTIONAL;
                                        this.rootSchemaTableTreeIterator = this.rootSchemaTableTrees.iterator();
                                        break;
                                    }
                                }
                            }
                        }
                        break;
                    case OPTIONAL:
                        if (this.elements != null) {
                            return true;
                        } else {
                            if (this.queryResult != null) {
                                iterateOptionalQueries();
                                this.first = false;
                            }
                            if (this.elements == null) {
                                closePreparedStatement();
                                //try the next distinctQueryStack
                                if (this.optionalLeftJoinResultsIterator.hasNext()) {
                                    this.optionalCurrentLeftJoinResult = this.optionalLeftJoinResultsIterator.next();
                                    this.subQueryStacks = SchemaTableTree.splitIntoSubStacks(this.optionalCurrentLeftJoinResult.getLeft());
                                    this.currentRootSchemaTableTree.resetColumnAliasMaps();
                                    executeOptionalQuery();
                                    this.first = true;
                                } else {
                                    //try the next rootSchemaTableTree
                                    if (this.rootSchemaTableTreeIterator.hasNext()) {
                                        this.currentRootSchemaTableTree = this.rootSchemaTableTreeIterator.next();
                                        List<Pair<LinkedList<SchemaTableTree>, Set<SchemaTableTree>>> leftJoinResult = new ArrayList<>();
                                        SchemaTableTree.constructDistinctOptionalQueries(this.currentRootSchemaTableTree, leftJoinResult);
                                        this.optionalLeftJoinResultsIterator = leftJoinResult.iterator();
                                    } else {
                                        if (this.currentRootSchemaTableTree != null) {
                                            this.currentRootSchemaTableTree.resetColumnAliasMaps();
                                        }
                                        this.queryState = QUERY.EMIT;
                                        this.rootSchemaTableTreeIterator = this.rootSchemaTableTrees.iterator();
                                        break;
                                    }
                                }
                            }
                        }
                        break;
                    case EMIT:
                        if (this.elements != null) {
                            return true;
                        } else {
                            if (this.queryResult != null) {
                                iterateEmitQueries();
                                this.first = false;
                            }
                            if (this.elements == null) {
                                closePreparedStatement();
                                //try the next distinctQueryStack
                                if (this.emitLeftJoinResultsIterator.hasNext()) {
                                    this.emitCurrentLeftJoinResult = this.emitLeftJoinResultsIterator.next();
                                    this.subQueryStacks = SchemaTableTree.splitIntoSubStacks(this.emitCurrentLeftJoinResult);
                                    this.currentRootSchemaTableTree.resetColumnAliasMaps();
                                    executeEmitQuery();
                                    this.first = true;
                                } else {
                                    //try the next rootSchemaTableTree
                                    if (this.rootSchemaTableTreeIterator.hasNext()) {
                                        this.currentRootSchemaTableTree = this.rootSchemaTableTreeIterator.next();
                                        List<LinkedList<SchemaTableTree>> leftJoinResult = new ArrayList<>();
                                        SchemaTableTree.constructDistinctEmitBeforeQueries(this.currentRootSchemaTableTree, leftJoinResult);
                                        this.emitLeftJoinResultsIterator = leftJoinResult.iterator();
                                        if (currentRootSchemaTableTree.isFakeEmit()) {
                                            List<Emit<SqlgElement>> fake = new ArrayList<>();
                                            fake.add(new Emit<>());
                                            this.elements = fake;
                                            this.currentRootSchemaTableTree.setFakeEmit(false);
                                        }
                                    } else {
                                        if (this.currentRootSchemaTableTree != null) {
                                            this.currentRootSchemaTableTree.resetColumnAliasMaps();
                                        }
                                        return false;
                                    }
                                }
                            }
                        }
                        break;
                }
            }
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }
266715
@Override
    public void clear() {
        RocksIterator iterator = db.newIterator();
        while (iterator.isValid())
            try {
                db.remove(iterator.key());
            } catch (RocksDBException e) {
                throw new RuntimeException(e);
            }
        iterator.close();
        size = 0;
    }
558286
public void remove() throws DBException
    {
        super.remove();
        Iterator<BaseTable> iterator = this.getTables();
        while (iterator.hasNext())
        {
            BaseTable table = iterator.next();
            if ((table != null) && (table != this.getNextTable()))
            {
                if ((table.getRecord().getEditMode() == Constants.EDIT_IN_PROGRESS) || (table.getRecord().getEditMode() == Constants.EDIT_CURRENT))
                    table.remove();
            }
        }
    }
1282979
public function hasOnDelete()
    {
        $database = $this->getTable()->getDatabase();
        if($database instanceof Database &&
               $this->onDelete === $database->getPlatform()->getDefaultFKOnDeleteBehavior()) {
          return false;
        }

        return ($this->onDelete !== self::NONE);
    }
78254
def remove(self, db):
        
        assert self.collection
        assert self.id

        db[self.collection].remove(self.id)
610228
public void clear()
    {
        Class collClass = getCollectionClass();

        // ECER: assure we notify all objects being removed, 
        // necessary for RemovalAwareCollections...
        if (IRemovalAwareCollection.class.isAssignableFrom(collClass))
        {
            getData().clear();
        }
        else
        {
            Collection coll;
            // BRJ: use an empty collection so isLoaded will return true
            // for non RemovalAwareCollections only !! 
            try
            {
                coll = (Collection) collClass.newInstance();
            }
            catch (Exception e)
            {
                coll = new ArrayList();
            }

            setData(coll);
        }
        _size = 0;
    }
1274862
@Override
    public boolean retainAll(Collection<?> c) {
        boolean modified = false;
        for(Map.Entry<Integer, Record> e : entries()) {
            Integer rId = e.getKey();
            Record r = e.getValue();
            if(!c.contains(r)) {
                remove(rId);
                modified = true;
            }
        }
        if(modified) {
            recalculateMeta();
        }
        return modified;
    }
1344873
@Override
	public boolean addAll(Collection<? extends T> collection) {
		boolean changed = false;
		for (T data : collection) {
			try {
				if (addElement(data)) {
					changed = true;
				}
			} catch (SQLException e) {
				throw new IllegalStateException("Could not create data elements in dao", e);
			}
		}
		return changed;
	}
1372189
public boolean remove(Object o) {
        boolean removed = false;
        for (Set<T> s : sets)
            if (s.remove(o))
                removed = true;
        return removed;
    }
1341149
@Override
	public boolean retainAll(Collection<?> collection) {
		if (booleanTerms == null) {
			return false;
		}
		return booleanTerms.retainAll(collection);
	}
955538
public void free()
    {
        this.setPDatabaseParent(null); // Remove from database
        
        Object[] keys = m_htTableList.keySet().toArray();
        for (int i = 0; i < keys.length; i++)
        { 
            Object key = keys[i];
            PTable pTable = m_htTableList.get(key);
            if (pTable != null)
                pTable.free();      // This can be dangerous if the PhysicalTables still have references to the PTables
        } 
        m_htTableList.clear();
        m_htTableList = null;
        this.close();
    }
951201
public boolean onDelete()
    {
        Record record = this.getMainRecord();
        if (record == null)
            return false;

        if (record.getEditMode() == Constants.EDIT_NONE)
            return true;
        if (record.getEditMode() == Constants.EDIT_ADD)
        {   // If they're adding, can't delete nothing!
            this.onRefresh();
            return true;
        }
        try {
            if (record.getEditMode() != Constants.EDIT_IN_PROGRESS)
                record.edit();
            record.remove();
            record.addNew();
            this.clearStatusText();
        } catch(DBException ex) {
            this.displayError(ex);
            return false;
        }
        return true;
    }
753580
public boolean removeItem (T item)
    {
        int index = _items.indexOf(item);
        if (index == -1) {
            return false;
        }
        _items.remove(index);
        removeItem(index);
        return true;
    }
143318
@Override
    public Map<K, V> clearAll() {
        Map<K, V> result = new LinkedHashMap<K, V>(map.size());

        for (Map.Entry<K, V> entry : map.entrySet()) {
            K key = entry.getKey();
            V value = entry.getValue();

            boolean removed = map.remove(key, value);

            if (removed) {
                result.put(key, value);
            }
        }

        return result;
    }