Package sets

Source Code of sets.StringSet

package sets;

import java.util.Collections;

import lipstone.joshua.parser.Parser;
import lipstone.joshua.parser.exceptions.ParserException;
import lipstone.joshua.parser.util.LengthComparison;

public class StringSet extends Set<String> {
 
  /**
   * Constructs a new <tt>StringSet</tt> from a comma-separated list of items
   *
   * @param list
   *            the comma-separated list
   * @throws ParserException
   */
  public StringSet(String list) throws ParserException {
    this.set.addAll(Parser.fromCommaList(list));
  }
 
  /**
   * Sorts this set by length
   */
  public void sortByLength() {
    Collections.sort(set, new LengthComparison());
  }
 
  /**
   * Sorts this set using Java's standard <tt>String</tt> comparisons
   */
  public void sort() {
    Collections.sort(set);
  }
}
TOP

Related Classes of sets.StringSet

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.