empty_collections library

The package empty_collections contains const implementations for several collection classes that allow access to there remove-functionality: EmptyIterator, EmptyIterable, EmptySet, EmptyMap, EmptyList, EmptyLinkedList and EmptyQueue. All these classes have been implemented as permanently empty collection class which are instanciable by a const constructor. This makes these classes quite efficient and e.g. usefull as default arguments for optional parameters. The difference from other unmodifiable implementations (e.g. const [], const {}, const UnmodifiableSetView.empty() from the collection package) is that these classes don't adhere to the unmodifiable convention that disallows both adding methodes (like add(...), insert(...), putIfAbsent(...), []=, ...) and removing methodes (like remove(...), clear(), retainWhere(...), ...). The thing is for empty collections the normal remove semantic doesn't change the state of the collection! E.g. a call to emptySet.clear() does nothing on an empty set, a call to emptyList.remove(o) will just return false, because o wasn't an element of the empty list to start with. So there is no harm in allowing remove-functionality while the adding-functionlity is still of limits.

Classes

EmptyIterable<E>
EmptyIterator<E>
EmptyLinkedList<E extends LinkedListEntry<E>>
An empty linked list that doesn't allow adding-operations (like add). Removing-operations (like remove and clear) are ok, because the don't modify the contents of an empty linked list.
EmptyList<E>
An empty list that doesn't allow adding-operations. Removing-operations (like remove, clear, retainWhere, ...) are ok, because the don't modify the contents of an empty list.
EmptyMap<K, V>
An empty map that doesn't allow adding-operations (like putIfAbsent or the []=operator). Removing-operations (remove and clear) are ok, because the don't modify the contents of an empty map.
EmptyQueue<E>
An empty queue that doesn't allow adding-operations (like add). Removing-operations (like remove and clear) are ok, because the don't modify the contents of an empty queue.
EmptySet<E>
An empty set that doesn't allow adding-operations. Removing-operations (like remove, clear, retainWhere, ...) are ok, because the don't modify the contents of an empty set.