pl.netanel.swt.matrix
Interface NumberSet<N extends java.lang.Number>

All Superinterfaces:
java.lang.Iterable<N>, NumberCollection<N>
All Known Subinterfaces:
NumberList<N>

public interface NumberSet<N extends java.lang.Number>
extends NumberCollection<N>

Represents a set of unique numbers.


Nested Class Summary
static class NumberSet.Query<N extends java.lang.Number>
          Deprecated. use NumberCollection.seq(int, Number, Number)
 
Method Summary
 boolean add(Extent<N> extent)
          Adds the given extent of numbers to the set.
 boolean add(N number)
          Adds the given number to the set.
 boolean add(N start, N end)
          Adds an extent of numbers between start end end to the set.
 boolean add(NumberCollection<N> set)
          Adds the content of the given set to this set.
 boolean addAll(NumberSet<N> set)
          Deprecated. Use add(NumberCollection)
 boolean change(N start, N end, boolean add)
          Calls add(Number, Number) if add is true otherwise remove(Number, Number) is called.
 boolean clear()
          Removes all of the numbers from this set.
 NumberSet<N> copy()
          Deprecated. use copyNumberSet(), becuase copy cannot be overriden by subclasses in a type safe manner similarily as the #clone() method cannot.
 NumberSet<N> copyNumberSet()
          Returns a copy of this set.
 void delete(Extent<N> extent)
          Deprecated. use Section.adjust(Number, Number)
 void delete(N number)
          Deprecated. Use Section.adjust(Number, Number)
 void delete(N start, N end)
          Deprecated. Use Section.adjust(Number, Number)
 java.util.Iterator<Extent<N>> extentIterator(NumberSet.Query<N> query)
          Returns an extent iterator according to the given query.
 NumberSet<N> getUnchecked()
          Returns a better performing but less user friendly implementation for this number set that is more loop efficient: does not check validity of the method arguments does not mark the layout as required computing on every method call, instead relying on the client to call Matrix.refresh()
 void insert(N target, N count)
          Deprecated. Use Section.adjust(Number, Number)
 java.util.Iterator<N> numberIterator(NumberSet.Query<N> query)
          Returns an number iterator according to the given query.
 boolean remove(Extent<N> extent)
          Removes the given extent of numbers from this set.
 boolean remove(N number)
          Removes the given number from this set.
 boolean remove(N start, N end)
          Removes an extent of numbers between start end end from this set.
 boolean remove(NumberCollection<N> set)
          Removes the content of the given set from this set.
 boolean removeAll(NumberSet<N> set)
          Deprecated. Use remove(NumberCollection)
 boolean toggle(N n)
          If the given number is present in this set then it is removed, otherwise it is added to this set.
 
Methods inherited from interface pl.netanel.swt.matrix.NumberCollection
contains, contains, contains, containsAll, containsAll, containsAll, containsAny, containsAny, containsAny, copyNumberCollection, getCount, getCount, isEmpty, seq, seq
 
Methods inherited from interface java.lang.Iterable
iterator
 

Method Detail

add

boolean add(N start,
            N end)
Adds an extent of numbers between start end end to the set. Adding extents performs better then adding single numbers.

Parameters:
start - first index of the range of items
end - last index of the range of items
Returns:
true if this operation has changed the set content.

add

boolean add(N number)
Adds the given number to the set.

Parameters:
number - to be added
Returns:
true if this operation has changed the set content.

add

boolean add(Extent<N> extent)
Adds the given extent of numbers to the set. Adding extents performs better then adding single numbers.

Parameters:
extent - the range of items to add
Returns:
true if this operation has changed the set content.

add

boolean add(NumberCollection<N> set)
Adds the content of the given set to this set.

Parameters:
set - to be added
Returns:
true if this operation has changed the set content.

addAll

@Deprecated
boolean addAll(NumberSet<N> set)
Deprecated. Use add(NumberCollection)

Adds the content of the given set to this set.

Parameters:
set - to be added
Returns:
true if this operation has changed the set content.

remove

boolean remove(N start,
               N end)
Removes an extent of numbers between start end end from this set. Removing extents performs better then adding single numbers.

Parameters:
start - first index of the range of items
end - last index of the range of items
Returns:
true if this operation has changed the set content.

remove

boolean remove(N number)
Removes the given number from this set.

Parameters:
number - to remove.
Returns:
true if this operation has changed the set content.

remove

boolean remove(Extent<N> extent)
Removes the given extent of numbers from this set. Removing extents performs better then adding single numbers.

Parameters:
extent - the range of items to remove
Returns:
true if this operation has changed the set content.

remove

boolean remove(NumberCollection<N> set)
Removes the content of the given set from this set.

Parameters:
set - to remove
Returns:
true if this operation has changed the set content.

removeAll

@Deprecated
boolean removeAll(NumberSet<N> set)
Deprecated. Use remove(NumberCollection)

Removes the content of the given set from this set.

Parameters:
set - to remove
Returns:
true if this operation has changed the content of the set

toggle

boolean toggle(N n)
If the given number is present in this set then it is removed, otherwise it is added to this set.

Parameters:
n - number to be added or removed
Returns:
true if this operation has changed the content of the set

clear

boolean clear()
Removes all of the numbers from this set. The set will be empty after this call returns.


change

boolean change(N start,
               N end,
               boolean add)
Calls add(Number, Number) if add is true otherwise remove(Number, Number) is called.

Parameters:
start - first index of the range of items
end - last index of the range of items
add - determines whether the given range is added or removed
Returns:
true if this operation has changed the content of the set

insert

@Deprecated
void insert(N target,
                       N count)
Deprecated. Use Section.adjust(Number, Number)

Inserts numbers before the given target number increasing the following numbers by the amount of the inserted numbers.

Numbers are inserted before the given target number or at the end if the target equals to the (last number in the set) + 1.

Parameters:
target - the number before which the new numbers are inserted
count - the number of items to insert
Throws:
java.lang.IndexOutOfBoundsException - if target or count is null
java.lang.IndexOutOfBoundsException - if target is out of 0 ... NumberCollection.getCount() bounds
java.lang.IllegalArgumentException - if start is greater then end

delete

@Deprecated
void delete(N start,
                       N end)
Deprecated. Use Section.adjust(Number, Number)

Removes a range of numbers decreasing the following numbers by the amount of the removed items.

Parameters:
start - first index of the range of items
end - last index of the range of items
Throws:
java.lang.IndexOutOfBoundsException - if start or end is null
java.lang.IndexOutOfBoundsException - if start or end is negative
java.lang.IllegalArgumentException - if start is greater then end

delete

@Deprecated
void delete(N number)
Deprecated. Use Section.adjust(Number, Number)

Removes a range of numbers decreasing the following numbers by 1.

Parameters:
number - number to be deleted
Throws:
java.lang.IndexOutOfBoundsException - if number is null
java.lang.IndexOutOfBoundsException - if number is negative
java.lang.IllegalArgumentException - if start is greater then end

delete

@Deprecated
void delete(Extent<N> extent)
Deprecated. use Section.adjust(Number, Number)

Removes a range of numbers decreasing the following numbers by the amount of the removed items.

Parameters:
extent - first index of the range of items to remove
Throws:
java.lang.IndexOutOfBoundsException - if extent is null

extentIterator

java.util.Iterator<Extent<N>> extentIterator(NumberSet.Query<N> query)
Returns an extent iterator according to the given query.

Parameters:
query - parameters changing the default iteration which is forward over all items. See NumberSet.Query. null value means the default query.
Returns:
extent iterator according to the given query

numberIterator

java.util.Iterator<N> numberIterator(NumberSet.Query<N> query)
Returns an number iterator according to the given query.

Parameters:
query - parameters changing the default iteration which is forward over all items. See NumberSet.Query. null value means the default query.
Returns:
number iterator according to the given query

copy

@Deprecated
NumberSet<N> copy()
Deprecated. use copyNumberSet(), becuase copy cannot be overriden by subclasses in a type safe manner similarily as the #clone() method cannot.

Returns a copy of this set.

Returns:
copy of this set

copyNumberSet

NumberSet<N> copyNumberSet()
Returns a copy of this set.

Returns:
copy of this set

getUnchecked

NumberSet<N> getUnchecked()
Returns a better performing but less user friendly implementation for this number set that is more loop efficient:

Returns:
a better performing but less user friendly implementation for this set


Copyright © 2011 netanel.pl. All Rights Reserved.