TUM CCSM Commons

edu.tum.cs.commons.region
Class RegionSet

java.lang.Object
  extended by edu.tum.cs.commons.region.RegionSet
All Implemented Interfaces:
java.lang.Iterable<Region>, java.util.Collection<Region>, java.util.Set<Region>

public class RegionSet
extends java.lang.Object
implements java.util.Set<Region>

Set of Region objects. Allows tests for containment on the entire set of regions.

Version:
$Revision: 28341 $
Author:
Elmar Juergens, hummelb, $Author: hummelb $
Rating:
GREEN Hash: 0F1BFF347A1A8FDD1F8580C3D546435D

Field Summary
static java.lang.String ANONYMOUS
          Name that is used if RegionSet is created without name
 
Constructor Summary
RegionSet()
          Creates an unnamed region set.
RegionSet(java.lang.String name)
          Creates a named RegionSet.
 
Method Summary
 boolean add(Region o)
          
 boolean addAll(java.util.Collection<? extends Region> c)
          
 void clear()
          
 boolean contains(int position)
          Returns true if the position is contained in one of the Regions in the RegionSet
 boolean contains(java.lang.Object o)
          
 boolean contains(Region region)
          Tests whether all of the positions of the region are contained in the RegionSet
 boolean containsAll(java.util.Collection<?> c)
          
 boolean containsAny(Region region)
          Tests whether any of the positions in the region are contained in the RegionSet.
 RegionSet createInverted(java.lang.String name, int lastPosition)
          Creates a new RegionSet whose regions are a complement to this RegionSet.
 boolean equals(java.lang.Object o)
          
 int getFirstPosition()
          Returns first position in RegionSet.
 int getLastPosition()
          Returns last position in RegionSet.
 java.lang.String getName()
          Returns the name.
 int getPositionCount()
          Gets the number of positions contained in the RegionSet.
 int hashCode()
          
 boolean isEmpty()
          
 java.util.Iterator<Region> iterator()
          
 boolean positionsEqual(RegionSet other)
          Returns true if both RegionSets contain the same positions and gaps.
 boolean remove(java.lang.Object o)
          
 boolean removeAll(java.util.Collection<?> c)
          
 boolean retainAll(java.util.Collection<?> c)
          
 int size()
          
 java.lang.Object[] toArray()
          
<T> T[]
toArray(T[] a)
          
 java.lang.String toString()
          
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ANONYMOUS

public static final java.lang.String ANONYMOUS
Name that is used if RegionSet is created without name

See Also:
Constant Field Values
Constructor Detail

RegionSet

public RegionSet(java.lang.String name)
Creates a named RegionSet.

Parameters:
name - Name of this region set.

RegionSet

public RegionSet()
Creates an unnamed region set.

Method Detail

getName

public java.lang.String getName()
Returns the name.


contains

public boolean contains(int position)
Returns true if the position is contained in one of the Regions in the RegionSet


contains

public boolean contains(Region region)
Tests whether all of the positions of the region are contained in the RegionSet


containsAny

public boolean containsAny(Region region)
Tests whether any of the positions in the region are contained in the RegionSet.


getPositionCount

public int getPositionCount()
Gets the number of positions contained in the RegionSet. This corresponds to the (non-overlapping) sum of the length of the regions.


getLastPosition

public int getLastPosition()
Returns last position in RegionSet.

Throws:
java.lang.IllegalStateException - if RegionSet is empty

getFirstPosition

public int getFirstPosition()
Returns first position in RegionSet.

Throws:
java.lang.IllegalStateException - if RegionSet is empty

createInverted

public RegionSet createInverted(java.lang.String name,
                                int lastPosition)
Creates a new RegionSet whose regions are a complement to this RegionSet. Inversion is relative to the interval [0, last position]


positionsEqual

public boolean positionsEqual(RegionSet other)
Returns true if both RegionSets contain the same positions and gaps.


toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object

add

public boolean add(Region o)

Specified by:
add in interface java.util.Collection<Region>
Specified by:
add in interface java.util.Set<Region>

addAll

public boolean addAll(java.util.Collection<? extends Region> c)

Specified by:
addAll in interface java.util.Collection<Region>
Specified by:
addAll in interface java.util.Set<Region>

clear

public void clear()

Specified by:
clear in interface java.util.Collection<Region>
Specified by:
clear in interface java.util.Set<Region>

contains

public boolean contains(java.lang.Object o)

Specified by:
contains in interface java.util.Collection<Region>
Specified by:
contains in interface java.util.Set<Region>

containsAll

public boolean containsAll(java.util.Collection<?> c)

Specified by:
containsAll in interface java.util.Collection<Region>
Specified by:
containsAll in interface java.util.Set<Region>

equals

public boolean equals(java.lang.Object o)

Specified by:
equals in interface java.util.Collection<Region>
Specified by:
equals in interface java.util.Set<Region>
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()

Specified by:
hashCode in interface java.util.Collection<Region>
Specified by:
hashCode in interface java.util.Set<Region>
Overrides:
hashCode in class java.lang.Object

isEmpty

public boolean isEmpty()

Specified by:
isEmpty in interface java.util.Collection<Region>
Specified by:
isEmpty in interface java.util.Set<Region>

iterator

public java.util.Iterator<Region> iterator()

Specified by:
iterator in interface java.lang.Iterable<Region>
Specified by:
iterator in interface java.util.Collection<Region>
Specified by:
iterator in interface java.util.Set<Region>

remove

public boolean remove(java.lang.Object o)

Specified by:
remove in interface java.util.Collection<Region>
Specified by:
remove in interface java.util.Set<Region>

removeAll

public boolean removeAll(java.util.Collection<?> c)

Specified by:
removeAll in interface java.util.Collection<Region>
Specified by:
removeAll in interface java.util.Set<Region>

retainAll

public boolean retainAll(java.util.Collection<?> c)

Specified by:
retainAll in interface java.util.Collection<Region>
Specified by:
retainAll in interface java.util.Set<Region>

size

public int size()

Specified by:
size in interface java.util.Collection<Region>
Specified by:
size in interface java.util.Set<Region>

toArray

public java.lang.Object[] toArray()

Specified by:
toArray in interface java.util.Collection<Region>
Specified by:
toArray in interface java.util.Set<Region>

toArray

public <T> T[] toArray(T[] a)

Specified by:
toArray in interface java.util.Collection<Region>
Specified by:
toArray in interface java.util.Set<Region>

TUM CCSM Commons

TUM CCSM Commons - 2.7