TUM CCSM Commons

edu.tum.cs.commons.region
Class RegionSet

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

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

Field Detail

ANONYMOUS

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

See Also:
Constant Field Values
Constructor Detail

RegionSet

public RegionSet(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 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:
IllegalStateException - if RegionSet is empty

getFirstPosition

public int getFirstPosition()
Returns first position in RegionSet.

Throws:
IllegalStateException - if RegionSet is empty

createInverted

public RegionSet createInverted(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 String toString()

Overrides:
toString in class Object

add

public boolean add(Region o)

Specified by:
add in interface Collection<Region>
Specified by:
add in interface Set<Region>

addAll

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

Specified by:
addAll in interface Collection<Region>
Specified by:
addAll in interface Set<Region>

clear

public void clear()

Specified by:
clear in interface Collection<Region>
Specified by:
clear in interface Set<Region>

contains

public boolean contains(Object o)

Specified by:
contains in interface Collection<Region>
Specified by:
contains in interface Set<Region>

containsAll

public boolean containsAll(Collection<?> c)

Specified by:
containsAll in interface Collection<Region>
Specified by:
containsAll in interface Set<Region>

equals

public boolean equals(Object o)

Specified by:
equals in interface Collection<Region>
Specified by:
equals in interface Set<Region>
Overrides:
equals in class Object

hashCode

public int hashCode()

Specified by:
hashCode in interface Collection<Region>
Specified by:
hashCode in interface Set<Region>
Overrides:
hashCode in class Object

isEmpty

public boolean isEmpty()

Specified by:
isEmpty in interface Collection<Region>
Specified by:
isEmpty in interface Set<Region>

iterator

public Iterator<Region> iterator()

Specified by:
iterator in interface Iterable<Region>
Specified by:
iterator in interface Collection<Region>
Specified by:
iterator in interface Set<Region>

remove

public boolean remove(Object o)

Specified by:
remove in interface Collection<Region>
Specified by:
remove in interface Set<Region>

removeAll

public boolean removeAll(Collection<?> c)

Specified by:
removeAll in interface Collection<Region>
Specified by:
removeAll in interface Set<Region>

retainAll

public boolean retainAll(Collection<?> c)

Specified by:
retainAll in interface Collection<Region>
Specified by:
retainAll in interface Set<Region>

size

public int size()

Specified by:
size in interface Collection<Region>
Specified by:
size in interface Set<Region>

toArray

public Object[] toArray()

Specified by:
toArray in interface Collection<Region>
Specified by:
toArray in interface Set<Region>

toArray

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

Specified by:
toArray in interface Collection<Region>
Specified by:
toArray in interface Set<Region>

TUM CCSM Commons

TUM CCSM Commons - 2.7