org.opcfoundation.ua.utils
Class BijectionMap<L,R>

java.lang.Object
  extended by org.opcfoundation.ua.utils.BijectionMap<L,R>

public class BijectionMap<L,R>
extends Object

Bijection map is a 1:1 binding of 2-tuples. For each binding one value has role "left" and the other one the role "right".

Author:
Toni Kalajainen

Constructor Summary
BijectionMap()
           
 
Method Summary
 void addAll(BijectionMap<L,R> map)
          addAll.
 void clear()
          Clear all bindings
 boolean contains(L leftValue, R rightValue)
          Contains binding
 boolean containsLeft(L leftValue)
          containsLeft.
 boolean containsRight(R rightValue)
          containsRight.
 Set<Map.Entry<L,R>> getEntries()
          getEntries.
 L getLeft(R rightValue)
          Get left value with right key
 Set<L> getLeftSet()
          Get all left values
 R getRight(L leftValue)
          Get right value with left key
 Set<R> getRightSet()
          Get all right values.
 boolean isEmpty()
          isEmpty.
 void map(L leftValue, R rightValue)
          Add value to the map
 R removeWithLeft(L leftValue)
          Remove a binding with left key
 L removeWithRight(R rightValue)
          Remove a binding with right key
 boolean retainAllLeft(Collection<L> values)
          retainAllLeft.
 boolean retainAllRight(Collection<R> values)
          retainAllRight.
 int size()
          Get the number of mappings
 String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BijectionMap

public BijectionMap()
Method Detail

addAll

public void addAll(BijectionMap<L,R> map)

addAll.

Parameters:
map - a BijectionMap object.

retainAllLeft

public boolean retainAllLeft(Collection<L> values)

retainAllLeft.

Parameters:
values - a Collection object.
Returns:
a boolean.

retainAllRight

public boolean retainAllRight(Collection<R> values)

retainAllRight.

Parameters:
values - a Collection object.
Returns:
a boolean.

getEntries

public Set<Map.Entry<L,R>> getEntries()

getEntries.

Returns:
a Set object.

containsLeft

public boolean containsLeft(L leftValue)

containsLeft.

Parameters:
leftValue - a L object.
Returns:
a boolean.

containsRight

public boolean containsRight(R rightValue)

containsRight.

Parameters:
rightValue - a R object.
Returns:
a boolean.

contains

public boolean contains(L leftValue,
                        R rightValue)
Contains binding

Parameters:
leftValue - a L object.
rightValue - a R object.
Returns:
true if there is a mapping between left and right value

map

public void map(L leftValue,
                R rightValue)
Add value to the map

Parameters:
leftValue - a L object.
rightValue - a R object.

isEmpty

public boolean isEmpty()

isEmpty.

Returns:
a boolean.

size

public int size()
Get the number of mappings

Returns:
the number of mappings

getLeft

public L getLeft(R rightValue)
Get left value with right key

Parameters:
rightValue - a R object.
Returns:
left value

getRight

public R getRight(L leftValue)
Get right value with left key

Parameters:
leftValue - a L object.
Returns:
right vlaue

removeWithLeft

public R removeWithLeft(L leftValue)
Remove a binding with left key

Parameters:
leftValue - a L object.
Returns:
old right value

removeWithRight

public L removeWithRight(R rightValue)
Remove a binding with right key

Parameters:
rightValue - a R object.
Returns:
old left value

getLeftSet

public Set<L> getLeftSet()
Get all left values

Returns:
all left values

getRightSet

public Set<R> getRightSet()
Get all right values.

Returns:
all right values

clear

public void clear()
Clear all bindings


toString

public String toString()

Overrides:
toString in class Object


Copyright © 2018. All rights reserved.