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
0
votes
1 answer

Grails - Apache Commons Collection vulnerability

Regarding the following vulnerability found in the commons-collections library, https://www.kb.cert.org/vuls/id/576313 I’ve found that the affected version 3.2.1 is pulled into hibernate (3.6.10.18) in the Grails project I am running under…
dre
  • 1,027
  • 1
  • 11
  • 31
0
votes
2 answers

How to deserialize custom Map with GSON

I am using Apache Collection's BidiMap which offers DualHashBidiMap class. I have to use this class for the project. There is no problem with serialization with it. But I have problem with deserializition!. Here is a sample class : package…
0
votes
2 answers

How remove duplicate from collection based on condition using Guava or Commons Collections

I have list of object array with employee details. I need to find the duplicate employee based on the employee ID and remove the details of old emplyee using create date. I need to do this using either Google Guava or Apache Commons Collection.
Krieger
  • 31
  • 1
  • 6
0
votes
1 answer

Performance of the Java CircularFifoQueue

i'm having a little trouble understanding how the CircularFifoQueue Class works. So for my requirements, i need a FIFO Queue of fixed Size (about 6000 Elements). At frist i was using the ArrayDequeue, but it was performing rather badly. Then i read…
hh32
  • 170
  • 10
0
votes
1 answer

Represent List as SortedMap in Java?

Is there any wrapper in popular collection libraries, which implements wrapper for List so that it can be accessed both with List and SortedMap interfaces? The goal is to have indexes shifted on insert operation and autogenerated on…
Suzan Cioc
  • 29,281
  • 63
  • 213
  • 385
0
votes
1 answer

Removing duplicates CollectionUtils.collate method

I'm trying to find the union of two collections by using the CollectionUtils.collate method. This method comes from the package org.apache.commons.collections4 Here is the code portion : Collection tokensUnion2 = CollectionUtils.collate( …
kolam
  • 731
  • 4
  • 17
0
votes
1 answer

I want to sort using commons-collections4-4.0 ComparatorChain

When we use the latest commons-collections4-4.0jar, we get an error message as shown below regarding making a sort option with a usage of the ComparatorChain and the BeanComparator. Do you have any idea what's wrong with this? We use commons-bean…
0
votes
1 answer

Apache collections UnmodifiableSet to scala immutable Set

What should I do when I get this? java.lang.ClassCastException: org.apache.commons.collections.set.UnmodifiableSet cannot be cast to scala.collection.immutable.Set
Anton
  • 494
  • 5
  • 19
0
votes
2 answers

How to Update value in MultiValueMap for a specific key

I have a MultiValueMap like {3=[c-2, c-2], 2=[b-1, b-1], 1=[a-1, a-2, a-3]} At one point I have to update a single value of a specific key for example I have to update the key 2 like 2=[u-1,u-2] how can i do this?
ѕтƒ
  • 3,547
  • 10
  • 47
  • 78
0
votes
2 answers

Order of elements in MultiKeyMap

Recently I started using Apache Commons MultiKeyMap for some of my projects and in there I can have multiple values for a value. MultiKeyMap typePanelUnoMap = new MultiKeyMap(); I want to know whether we can preserve insertion order when using…
keth
  • 793
  • 2
  • 11
  • 36
0
votes
1 answer

apache-commons colectionutils source code

The following code snippet has been taken from Commons framework's CollectionUtils.java file: private static class CardinalityHelper { final Map cardinalityA, cardinalityB; public CardinalityHelper(final Iterable
0
votes
1 answer

GAE/J Memcache : Cannot use as a key

The GAE doc said: Keys and values can be of any Serializable type or class I use MultiKey as the key but after update my app, it gives me exception: java.lang.IllegalArgumentException: Cannot use as a key: 'MultiKey[class com.xx.xx.xx,…
Mike
  • 3,515
  • 10
  • 44
  • 67
-1
votes
1 answer

Unexpected behaviour of Apache Commons CollectionUtils addAll(Collection collection, Object[] elements)

Brief description: Basically, inside my code i want to add a List to every inside a ListValuedMap > as a . I did some testing on the created ListValuedMap spreadNormal…
Dorian Feyerer
  • 258
  • 5
  • 14
-1
votes
1 answer

Get Submap from Map using PredicateMap

I wanted to get a submap from predicateMap: I have tried this: public class first { public static void main(String[] args) { TreeMap myMap = new TreeMap(); Predicate onlyStrings = new InstanceofPredicate(…
1 2 3 4
5