void retainAll(Iterable<Object> elements) { // Build a set with the same sense of equality as this set. SplayTreeSet<E> retainSet = new SplayTreeSet<E>(_comparator, _validKey); int modificationCount = _modificationCount; for (Object object in elements) { if (modificationCount != _modificationCount) { // The iterator should not have side effects. throw new ConcurrentModificationError(this); } // Equivalent to this.contains(object). if (_validKey(object) && _splay(object) == 0) { retainSet.add(_root.key); } } // Take over the elements from the retained set, if it differs. if (retainSet._count != _count) { _root = retainSet._root; _count = retainSet._count; _modificationCount++; } }
© 2012 the Dart project authors
Licensed under the Creative Commons Attribution-ShareAlike License v4.0.
https://api.dartlang.org/stable/2.0.0/dart-collection/SplayTreeSet/retainAll.html