# Interface LinkSet

All Superinterfaces:
  `Iterable<RowLink>`

public interface LinkSet extends Iterable<RowLink>
Holds an unordered collection of unique `RowLink` objects. The set is understood to be mutable - that is the methods (including `iterator().remove()` should not throw `UnsupportedOperationException`s.

Although its methods are very similar to those of a `Set`, this is not a `Set` implementation. This is because it will have a pretty specialised use - in particular you should usually treat it as though it may contain a very large number of elements and hence think carefully about efficiency of access methods rather than take advantage of the convenience methods available in the Collections package.

Since:
  7 Sep 2005
Author:
  Mark Taylor

## Method Summary

Modifier and Type
Method
Description
`void`
`addLink(RowLink link)`
Adds a new link to this set.
`boolean`
`containsLink(RowLink link)`
Indicates whether this set contains a given link.
`Iterator<RowLink>`
`iterator()`
Returns an iterator over the elements of this set.
`boolean`
`removeLink(RowLink link)`
Removes an existing link from this set.
`int`
`size()`
Returns the number of items in this set.
`Collection<RowLink>`
`toSorted()`
Returns a collection of RowLink objects that has the same content as this LinkSet, but with entries in their natural (`Comparable`) order.

### Methods inherited from interface Iterable

`forEach, spliterator`

## Method Details

### addLink

void addLink(RowLink link)
Adds a new link to this set. If the set has any existing entries equivalent to `link` (by `equals`) they should be removed.

Parameters:
  `link` - row link to add

### containsLink

boolean containsLink(RowLink link)
Indicates whether this set contains a given link.

Parameters:
  `link` - link to test
Returns:
  true iff this set contains an entry equal to `link`

### removeLink

boolean removeLink(RowLink link)
Removes an existing link from this set.

Parameters:
  `link` - link to remove
Returns:
  true iff `link` was there in the first place

### iterator

Iterator<RowLink> iterator()
Returns an iterator over the elements of this set.

Specified by:
  `iterator` in interface `Iterable<RowLink>`
Returns:
  iterator, which should have a working `remove()` method

### size

int size()
Returns the number of items in this set.

Returns:
  set size

### toSorted

Collection<RowLink> toSorted()
Returns a collection of RowLink objects that has the same content as this LinkSet, but with entries in their natural (`Comparable`) order.

The result is not intended for modification; it may or may not be backed by this object, so subsequent modifications of this LinkSet while it's in use are not recommended.

Returns:
  unmodifiable sorted collection of the row links in this set