de.schlichtherle.truezip.util.CanonicalStringSet Maven / Gradle / Ivy
/*
* Copyright (C) 2005-2015 Schlichtherle IT Services.
* All rights reserved. Use is subject to license terms.
*/
package de.schlichtherle.truezip.util;
import java.util.AbstractSet;
import java.util.Iterator;
import java.util.NoSuchElementException;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeSet;
import javax.annotation.CheckForNull;
/**
* An abstract set of the canonical string representation of objects in
* natural sort order.
* An object is canonicalized by the idempotent function
* {@link Canonicalizer#map}.
*
* Canonical string sets can be converted from and to string lists by using
* {@link #addAll(String)} and {@link #toString()}.
* A string list is a string which consists of zero or more elements
* which are separated by the separator character provided to the
* constructor.
* Note that in general, a string list is just a sequence of strings elements.
* In particular, a string list may be empty (but not {@code null}) and
* its elements don't have to be in canonical form, may be duplicated in the
* list and may be listed in arbitrary order.
* However, string lists have a canonical form, too:
* A string list in canonical form (or canonical string list for short)
* is a string list which contains only canonical strings in natural sort order
* and does not contain any duplicates (so it's actually a set).
*
* Unless otherwise documented, all {@link java.util.Set} methods work on the
* canonical form of the string elements in this set.
*