CollectionDiscriminator

A CollectionDiscriminator discriminates Collections. It discriminates its input by creating a new ArrayList to be a shallow copy of the given Collection, then it uses a RandomAccessListDiscriminator to discriminate on the ArrayList. ArrayLists are RandomAccess, which means that element access should be constant-time. Collections are not necessarily RandomAccess.

Example

Given the input...

  • {Arrays.asList(1, 2, 3), new LinkedList(Arrays.asList(1, 2, 3)), new HashSet(Arrays.asList(1, 2, 3)), new ArrayList(Arrays.asList(1, 2, 3)), Arrays.asList(1, 2, 4), Arrays.asList(5), Arrays.asList(3, 2, 1)}

... a CollectionDiscriminator returns the following equivalence classes:

  • {Arrays.asList(1, 2, 4)}
  • {Arrays.asList(5)}
  • {Arrays.asList(3, 2, 1)}
  • {Arrays.asList(1, 2, 3), LinkedList(Arrays.asList(1, 2, 3), HashSet(Arrays.asList(1, 2, 3), ArrayList(Arrays.asList(1, 2, 3)}