commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Vimont <dan...@commonvox.org>
Subject Re: [COLLECTIONS] [DISCUSS] Possible candidate for inclusion in Commons-Collections: OrderedSet (provides composite-key based ordering of a set of values)
Date Fri, 08 Apr 2016 13:53:08 GMT
Thanks for the suggestion. I will look into emulating OrderedSet
functionality using the two classes you recommend.

Since all of the materials that I provided may be a bit on the "tl;dr"
side, I will focus on a single example:

Book class, with the following attribute get-methods:
  getAuthors -- returns collection of Author objects (a Book may have
multiple authors)
  getGenres -- returns collection of Genre objects (a Book may be
classified in multiple genres)
  getTitle -- returns a Title object (a Book has only one title)

Order these two Books by a Genre|Author|Title composite-key
  Book 1:
    Title: Dictionary of the English Language
    Genres: Nonfiction; Reference
    Authors: Merriam, George; Webster, Noah
  Book 2:
    Title: A Walk in the Woods
    Genres: Nonfiction; Travel; Quest
    Author: Bryson, Bill

Following construction and population of an OrderedSet, invocation of the
#entrySet method will return the following entries:

*Key-components (composite-key)               Value*
*==========================================   ========*
*Genre       Author           Title           Book*
*------      --------         ------          --------*
*Nonfiction  Bryson, Bill     A Walk...       Book 2*
*Nonfiction  Merriam, George  Dictionary...   Book 1*
*Nonfiction  Webster, Noah    Dictionary...   Book 1*
*Quest       Bryson, Bill     A Walk...       Book 2*
*Reference   Merriam, George  Dictionary...   Book 1*
*Reference   Webster, Noah    Dictionary...   Book 1*
*Travel      Bryson, Bill     A Walk...       Book 2*


On Fri, Apr 8, 2016 at 8:19 PM, James Carman <james@carmanconsulting.com>
wrote:

> Couldn't you achieve the same thing using any SortedSet and
> CompareToBuilder?
> On Fri, Apr 8, 2016 at 2:17 AM Daniel Vimont <daniel@commonvox.org> wrote:
>
> > Hello all,
> >
> > I've just published a new extension to the standard Java Collections
> > Framework to both GitHub and the Maven Central Repository, and am
> > considering offering it up for possible inclusion in the Apache Commons
> > Collections package.
> >
> > The name of the class is "OrderedSet", which is an abbreviated version of
> > its original working name, "CompositeKeyOrderedSet". As its previous
> > working name suggests, an OrderedSet provides for composite-key based
> > ordering of a set of values (analogous to composite-key ordering in a
> > relational database). To get a better sense of what that actually means,
> > the README text on the project's GitHub page provides a quick overview
> (or
> > dive down into the source code on the GitHub page, if you prefer):
> > https://github.com/dvimont/OrderedSet
> >
> > For more thorough end-user documentation, the project's Javadocs can be
> > consulted:
> > http://bit.ly/ordered-set
> >
> > I realize that "Apache Commons is a Commit-Then-Review community", but
> > before I go through the steps of preparing a patch for submission I
> wanted
> > to get some feedback, if possible, regarding whether this class would be
> > appropriate for inclusion in the Apache Commons Collections package, and
> to
> > be sure that its core functionality does not duplicate either (a) some
> > already-existing component of the package or (b) some alternate,
> well-known
> > (to all but me!) means of achieving automated composite-key-style
> ordering
> > (in Java 1.6+).
> >
> > Thanks very much,
> >
> > Dan Vimont
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message