On Wed, 23 Oct 2002, Michael A. Smith wrote:
> Henri Yandell wrote: > > I just pushed a ClassMap class in. Uses inheritence in the get, so you can > > do: > > > > map.put(Number.class, new NumberConverter()); > > > > Converter c = (Converter)map.get(Float.class); > > > > assuming a Converter class. > > I like, but I see some issues with the implementation with regards to > interfaces. I just commented on your cvs commit (did that before I saw > this message). > > > It doesn't do anything fancy with Integer.TYPE. ie) claiming that that > > extends Number.class etc. Any views? > > these would be special cases, right? dunno... I'll think about it > though. Thanks. I'll improve the documentation as you've suggested. Whether my particular inheritence strategy is correct, I don't know. Case of 'it makes sense to me and I can't see the wood for the trees'. > > Clearing out my collections package... > > Other things: > > > > I still need to add an isSorted to CollectionUtils, will go ahead and do > > that at some point. Making myself hold back until I have a unit-test is > > almost like hard work :) > > Now, if you add that to ListUtils and perform on lists, then that seems > reasonable. *whistle* ListUtils ListUtils. > > > I have a SortedIterator class. Basic usage being: > > .. > > Iterator iterator = ... > > SortedIterator si = new SortedIterator(iterator, new SomeComparator() ); > > .. > > Then it reads that iterator out in sorted order. Obviously has to suck it > > into memory internally. Anyone think this is of use? > > This same thing can be accomplished using the three-step: > > List l = IteratorUtils.toList(iterator); > Collections.sort(list, new SomeComparator()); > Iterator sorted = list.iterator(); > Thanks. This is good enough to not need a SortedIterator so I agree. > > OrderedSet -> Basically a List which doesn't allow duplicates. > > ok. > > > LimitedList -> A List which maintains a fixed max length. > > usefulness? Maybe an LRUList? As an inheritable class for the next is the only place I've used it so far :) > > > SortedLimitedList -> A List which uses a Comparator to maintain a sorted > > max length. Useful to do a quick sort to find the > > first N elements of a list of length L. > > <Insertion Sort> > > huh? I wanted to sort the top 50 of a list containing a thousand things. So I did a SortedLimitedList using a Comparator and a limit of 50. Rather than using Collections.sort, it uses insert-sort. So assuming L is large, and N is small enough, then it becomes possible in one step. Possibly this is all just a little too specific though :) > > typed.* a Map/List/Set wrapper which enforces the Type of the value or > > key. So you'd do: > > .. > > List list = new TypedList(Integer.class) > > .. > > and it will throw an Exception if u pass the wrong thing in. > > isn't this just a ListUtils.predicatedList(p) with a predicate, p, that > checks for the right class? > > maybe provide the predicate to construct such a thing? Kay. Hen -- To unsubscribe, e-mail: <mailto:commons-dev-unsubscribe@;jakarta.apache.org> For additional commands, e-mail: <mailto:commons-dev-help@;jakarta.apache.org>
