Home
Categories
Dictionary
Download
Project Details
Changes Log
FAQ
License

org.mdiutil.util.partialset



The partialset package contains additional classes which provides partial ordering sets. The work with the Java util package.

The classes used in this package are derived from the javax.imageio.spi package. This package is only distributed under the LGPL 2.1 license. It uses source code from the JDK.

Overview

The PartiallyOrderedHashSet and PartiallyOrderedTreeSet classes are Set implementations where the order of the elements in the Set is a partial order:
  • The PartiallyOrderedHashSet class specify a Set where some elements in the Set are ordered explictly
  • The PartiallyOrderedTreeSet class specify a Set where some elements in the Set are ordered explictly. The other elements are ordered by their natural order
Both the PartiallyOrderedHashSet and PartiallyOrderedTreeSet classes implement the PartiallyOrderedSet interface.

Adding an explicit ordering between two elements

The PartiallyOrderedSet interface has several methods to handle an explicit order between two elements:
It is not mandatory to order all elements. The Set will respect the specified orderings, and will iterate depending on the type of the Set for other elements.

Example

   PartiallyOrderedHashSet<String> set = new PartiallyOrderedHashSet<>();
   set.add("A");
   set.add("B");
   set.add("C");      
   set.add("D");
      
   set.setOrdering("D", "B"); 
   set.setOrdering("C", "A");
   set.setOrdering("A", "D"); 
      
   Iterator<String> it = set.iterator();
      
   String elt = it.next(); // elt is "C"
   elt = it.next(); // elt is "A"
   elt = it.next(); // elt is "D" 
   elt = it.next(); // elt is "B" 

See also


Categories: Packages | Util

Copyright 2006-2024 Herve Girod. All Rights Reserved. Documentation and source under the LGPL v2 and Apache 2.0 licences

Project Web Hosted by SourceForge.net Copyright 1999-2010 - Geeknet, Inc., All Rights Reserved About - Legal - Help