Questions tagged [apache-commons-collection]

Commons-Collections builds upon the Java collection classes by providing new interfaces, implementations and utilities.

Features listed from home page

  • Bag interface for collections that have a number of copies of each object
  • Buffer interface for collections that have a well defined removal order, like FIFOs
  • BidiMap interface for maps that can be looked up from value to key as well and key to value
  • MapIterator interface to provide simple and quick iteration over maps
  • Type checking decorators to ensure that only instances of a certain type can be added
  • Transforming decorators that alter each object as it is added to the collection
  • Composite collections that make multiple collections look like one
  • Ordered maps and sets that retain the order elements are added in, including an LRU based map
  • Identity map that compares objects based on their identity (==) instead of the equals method
  • Reference map that allows keys and/or values to be garbage collected under close control
  • Many comparator implementations
  • Many iterator implementations
  • Adapter classes from array and enumerations to collections
  • Utilities to test or create typical set-theory properties of collections such as union, intersection, and closure
74 questions
2
votes
2 answers

Is there a Comparator> or Comparator>?

I am searching for a class that implements one of the following java.util.Comparator java.util.Comparator> java.util.Comparator> Why is there no such class in the Java Standard Library / Apache Common / Google Guava ?
Morad
  • 734
  • 5
  • 14
2
votes
1 answer

java.lang.NoClassDefFoundError: com.sun.org.apache.commons.beanutils.PropertyUtils

i am trying to use apache commons collections and predicate as follows: List bigList = ....; // master list Collection smallList = CollectionUtils.select(bigList, new Predicate() { public boolean evaluate(Object o) { Cat c =…
Mahmoud Saleh
  • 33,303
  • 119
  • 337
  • 498
2
votes
2 answers

Is there any implementation of a MergeIterator?

Does any of the existing collection libraries (guava, commons-collection) provide a MergeIterator that's constructed with: MergeIterator(Iterator iters...) and then (assuming the source iterators are sorted) advances through the…
Bogdan Calmac
  • 7,993
  • 6
  • 51
  • 64
2
votes
3 answers

Existing Java collection that supports custom criteria for uniqueness?

I'd like to utilize a unique java collection that can accept a strategy for determining if member objects are "equal" on collection initialization. The reason I need to do this is because the equals method of the class that I need to add to this…
smp7d
  • 4,947
  • 2
  • 26
  • 48
2
votes
2 answers

Proper way to work with FIFO buffer

I have this FIFO which I'm going to use to store data from network server: Buffer nServerFifo = (Buffer) BufferUtils.synchronizedBuffer(new CircularFifoBuffer(200)); // Insert into to the Network Server Buffer public void…
user1285928
  • 1,328
  • 29
  • 98
  • 147
1
vote
1 answer

Convert Guava ListMultimap to Java Map

Guava MultiMap has implementations ImmutableListMultimap and ImmutableSetMultimap. Given that I have created an ImmutableListMultimap instance, how can I convert that into a java.util.Map>? The asMap() method…
tkruse
  • 10,222
  • 7
  • 53
  • 80
1
vote
1 answer

No standard wrapper implementation for MultiValuedMap

Am I missing something, or is there really no default implementation of Apache's new MultiValuedMap that could be used to simply wrap provided Map>? In other words, I am looking for a direct replacement of the now…
Andrei LED
  • 2,560
  • 17
  • 21
1
vote
1 answer

Difference between Apache commons-collections' synchronizedList() and java.util.Collections.synchronizedList()

Any difference between java.util.Collections.synchronizedList() and Apache commons-collections' ListUtils.synchronizedList(). Any reason to prefer one over the other?
Vaiden
  • 15,728
  • 7
  • 61
  • 91
1
vote
1 answer

How to use MultiKeyMap from Apache in Spring Framework

I have come across MultiKeyMap from Apache Commons and am interested in using it in Spring framework instead of using regular map as I have a need for double key map. Dpes anyone know how to use MultiKeyMap with Spring framework?
JUG
  • 693
  • 9
  • 25
1
vote
1 answer

Does Apache Commons Collections have a ListValuedTreeMap?

I'm trying to find a pre-built implementation of a MultiValuedTreeMap. In a nutshell, I need a single key to map to multiple values via the use of a List. I then need each key to be stored in a sorted structure, what I imagine should be a tree map -…
goastler
  • 223
  • 2
  • 6
1
vote
2 answers

Unable to locate ListOrderedMap?

I have included all the 6 jars (beanutils, lang, logging, collections, ezmorph, json-lib). Its working fine in simple struts application. But in my struts application, although I have included all jar files, its shows a NoClassDefFoundError about…
Manoj
  • 5,707
  • 19
  • 56
  • 86
1
vote
1 answer

Are newer apache commons libraries compatible with older ones

Specifically, I am interested are new line 4.x commons-collections library backward compatible with 3.x version.
1
vote
1 answer

How to use OrderedMapIterator.previous()

Using Apache Commons Collections I found the OrderedMapIterator interface to navigate back and forth in OrderedMap. Iterating to the next entry works as expected. Going to the previous element doesn't return the previous element but the current…
Roland Weisleder
  • 9,668
  • 7
  • 37
  • 59
1
vote
1 answer

How to make a diff between 2 ArrayLists

I am making a webserver that generates checker-like tiles Images on java. The class that models the checker is: package app.app.image; import app.app.image.iterate.ImageElementVisitorInterface; import app.app.image.tiles.Tile; import…
Dimitrios Desyllas
  • 9,082
  • 15
  • 74
  • 164
1
vote
2 answers

Java intersection Collection

I'd like to find an elegant way to this: I have two collections A and B, if they both are not empty, then I need to do the intersection (store common elements in another list). If one of them is empty I'll have to take all elements of the other. If…
user1820620
  • 672
  • 2
  • 13
  • 27