-
- All Known Subinterfaces:
IntIterableSet
- All Known Implementing Classes:
IntIterableBitSet
,IntIterableRangeSet
,Set_BitSet
,Set_CstInterval
,Set_FixedArray
,Set_LinkedList
,Set_ReadOnly
,Set_Std_BitSet
,Set_Std_Swap
,Set_Std_Swap2
,Set_Swap
,Set_Swap2
,StdSet
public interface ISet extends Iterable<Integer>
Class representing a set of integers Created by IntelliJ IDEA.- Since:
- 9 feb. 2011, update 2016
- Author:
- chameau, Jean-Guillaume Fages
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description boolean
add(int element)
Add element to the setvoid
clear()
Remove all elements from the setboolean
contains(int element)
Test the existence of element in the setSetType
getSetType()
default boolean
isEmpty()
ISetIterator
iterator()
Use the following loop to iterate over this set without autoboxing.int
max()
int
min()
ISetIterator
newIterator()
Creates a new iterator object, for nested loops only.boolean
remove(int element)
Remove the first occurrence of element from the setint
size()
default int[]
toArray()
Copies the set in an array if integers-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Method Detail
-
iterator
ISetIterator iterator()
Use the following loop to iterate over this set without autoboxing.// more readable but with autoboxing for(int value:set){ ... } // more verbose but without autoboxing ISetIterator iter = set.primitiveIterator(); while(iter.hasNext()){ int k = iter.next(); ... }
Do not use this iterator to make nested loops overISet
(prefernewIterator()
)
-
newIterator
ISetIterator newIterator()
Creates a new iterator object, for nested loops only.- Returns:
- a new iterator for this set
-
add
boolean add(int element)
Add element to the set- Parameters:
element
- element to add- Returns:
- true iff element was not in the set and has been added
-
remove
boolean remove(int element)
Remove the first occurrence of element from the set- Parameters:
element
- element to add- Returns:
- true iff element was in the set and has been removed
-
contains
boolean contains(int element)
Test the existence of element in the set- Parameters:
element
- element to add- Returns:
- true iff the set contains element
-
isEmpty
default boolean isEmpty()
- Returns:
- true iff the set is empty
-
size
int size()
- Returns:
- the number of elements in the set
-
clear
void clear()
Remove all elements from the set
-
min
int min()
- Returns:
- the smallest element in the set throws an exception if the set is empty Time complexity is linear for BIPARTITESET and LINKED_LIST (constant time otherwise)
-
max
int max()
- Returns:
- the largest element in the set throws an exception if the set is empty Time complexity is linear for BIPARTITESET and LINKED_LIST (constant time otherwise)
-
getSetType
SetType getSetType()
- Returns:
- the implementation type of this set
-
toArray
default int[] toArray()
Copies the set in an array if integers- Returns:
- an array containing every integer of the set
-
-