public class

MultiList

extends Object
java.lang.Object
   ↳ com.pnfsoftware.jeb.util.collect.MultiList<E>

Class Overview

A list of lists to be used as a fast-access multi-map for cases where the key is an integer index located in a compact [0, N] range. Use with caution: if the input key range is sparse, it is better to use a MultiMap.

Summary

Public Constructors
MultiList()
Create a new multi-list.
Public Methods
List<E> clear(int index)
Clear a bucket.
void clear()
List<E> findAllElements(int index, Predicate<E> check)
E findFirstElement(int index, Predicate<E> check)
List<E> get(int index)
Retrieve the elements stored in an indexed bucket.
NavigableSet<Integer> indexSet()
boolean isEmpty()
int put(int index, E elt)
Add an element to a bucket.
void putAll(List<List<? extends E>> c)
void putMulti(int index, Collection<? extends E> values)
Add multiple elements mapped by the same key.
List<E> remove(int index)
Remove a bucket and shift subsequent bucket entries.
boolean removeElement(int index, E value)
Remove an element from a bucket.
int removeMultipleElements(int index, Predicate<E> check)
Remove elements from a bucket.
int size()
Get the total number of elements stored in all the buckets.
String toString()
Collection<E> values()
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public MultiList ()

Create a new multi-list.

Public Methods

public List<E> clear (int index)

Clear a bucket. The bucket stays.

Returns
  • the list of elements that were in the cleared bucket, possibly empty, never null

public void clear ()

public List<E> findAllElements (int index, Predicate<E> check)

public E findFirstElement (int index, Predicate<E> check)

public List<E> get (int index)

Retrieve the elements stored in an indexed bucket.

Returns
  • a list, possibly empty, never null

public NavigableSet<Integer> indexSet ()

public boolean isEmpty ()

public int put (int index, E elt)

Add an element to a bucket.

public void putAll (List<List<? extends E>> c)

public void putMulti (int index, Collection<? extends E> values)

Add multiple elements mapped by the same key.

public List<E> remove (int index)

Remove a bucket and shift subsequent bucket entries. Eg, removing the bucket at index 10 means that buckets previously at indexes 11, 12, ..., N will be at indexes 10, 11, ..., N-1. Mind the unusual semantic of this operation.

Returns
  • the list of elements that were in the removed bucket, possibly empty, never null

public boolean removeElement (int index, E value)

Remove an element from a bucket.

Parameters
value the element to be removed

public int removeMultipleElements (int index, Predicate<E> check)

Remove elements from a bucket.

Returns
  • the number of elements removed

public int size ()

Get the total number of elements stored in all the buckets.

public String toString ()

public Collection<E> values ()