Idea: Combined TCollection interface
Issue #33
new
Defining parts of the Collection interfaces for each component type despite the fact that they have nothing to do with the component type seems wasteful. Also if someone wanted to have multiple implementations of a class using a T*Collection and abstract out the collection type, they need to wrap all the used methods into abstract methods.
Thus, having a parent interface with the methods not burdened with the component type could be helpful and remove duplication (javadoc omitted):
interface TCollection {
boolean isEmpty();
int size();
boolean equals(Object o);
int hashCode;
void clear();
void reverse();
void sort();
void sort(int from, int until);
void shuffle(Random random);
}
Comments (3)
-
-
reporter You're right, TCollections are unordered and thus should not be reversible/sortable/shuffleable. Looks good.
-
reporter I just wanted to add that T*Maps could also implement TCollection, as they don't have any other methods that aren't key- or value-related.
- Log in to comment
We could do: