Package dev.nm.misc.algorithm
Class ActiveSet
- java.lang.Object
-
- dev.nm.misc.algorithm.ActiveSet
-
public class ActiveSet extends Object
This class keeps track of the active and inactive indices.
-
-
Constructor Summary
Constructors Constructor Description ActiveSet(boolean sorted)Construct a working set of active/inactive indices.ActiveSet(boolean sorted, int[] indices)Construct a working set of active/inactive indices.ActiveSet(boolean sorted, Collection<Integer> indices)Construct a working set of active/inactive indices.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intactiveSize()Get the number of active indices.voidaddActive(int j)Add an active constraint by index.voidaddActive(int[] indices)Add active indices.voidaddActive(Collection<Integer> indices)Add active indices.voidaddInactive(int j)Add an inactive constraint by index.voidaddInactive(int[] indices)Add inactive indices.voidaddInactive(Collection<Integer> indices)Add inactive indices.booleancontainActive(int j)Check if the active set contains a certain index.booleancontainInactive(int j)Check if the inactive set contains a certain index.intgetActive(int i)Get the i-th active index.int[]getActiveIndices()Get all active indices.intgetInactive(int i)Get the i-th inactive index.int[]getInactiveIndices()Get all inactive indices.intinactiveSize()Get the number of inactive indices.voidremoveActive(int j)Remove an active index.voidremoveActiveByIndex(int i)Remove an active constraint by index.voidremoveInactive(int j)Remove an inactive index.voidremoveInactiveByIndex(int i)Remove an active constraint by index.StringtoString()
-
-
-
Constructor Detail
-
ActiveSet
public ActiveSet(boolean sorted)
Construct a working set of active/inactive indices.- Parameters:
sorted- indicator of whether the indices are sorted
-
ActiveSet
public ActiveSet(boolean sorted, Collection<Integer> indices)Construct a working set of active/inactive indices.- Parameters:
sorted- indicator of whether the indices are sortedindices- the active indices
-
ActiveSet
public ActiveSet(boolean sorted, int[] indices)Construct a working set of active/inactive indices.- Parameters:
sorted- indicator of whether the indices are sortedindices- the active indices
-
-
Method Detail
-
addActive
public void addActive(Collection<Integer> indices)
Add active indices.- Parameters:
indices- a collection of active constraint indices
-
addActive
public void addActive(int[] indices)
Add active indices.- Parameters:
indices- an array of active constraint indices
-
addInactive
public void addInactive(Collection<Integer> indices)
Add inactive indices.- Parameters:
indices- a collection of inactive constraint indices
-
addInactive
public void addInactive(int[] indices)
Add inactive indices.- Parameters:
indices- an array of inactive constraint indices
-
addActive
public void addActive(int j)
Add an active constraint by index.- Parameters:
j- an index of an active constraint
-
addInactive
public void addInactive(int j)
Add an inactive constraint by index.- Parameters:
j- an index of an inactive constraint
-
removeActive
public void removeActive(int j)
Remove an active index.- Parameters:
j- an active index to be removed.
-
removeInactive
public void removeInactive(int j)
Remove an inactive index.- Parameters:
j- an inactive index to be removed.
-
removeActiveByIndex
public void removeActiveByIndex(int i)
Remove an active constraint by index.- Parameters:
i- an active index, counting from 1
-
removeInactiveByIndex
public void removeInactiveByIndex(int i)
Remove an active constraint by index.- Parameters:
i- an inactive index, counting from 1
-
activeSize
public int activeSize()
Get the number of active indices.- Returns:
- the number of active indices
-
inactiveSize
public int inactiveSize()
Get the number of inactive indices.- Returns:
- the number of inactive indices
-
containActive
public boolean containActive(int j)
Check if the active set contains a certain index.- Parameters:
j- an index of an active constraint- Returns:
trueif the active set containsj
-
containInactive
public boolean containInactive(int j)
Check if the inactive set contains a certain index.- Parameters:
j- an index of an inactive constraint- Returns:
trueif the inactive set containsj
-
getActiveIndices
public int[] getActiveIndices()
Get all active indices.- Returns:
- all active indices
-
getInactiveIndices
public int[] getInactiveIndices()
Get all inactive indices.- Returns:
- all inactive indices
-
getActive
public int getActive(int i)
Get the i-th active index.- Parameters:
i- an index.- Returns:
- the i-th active index
-
getInactive
public int getInactive(int i)
Get the i-th inactive index.- Parameters:
i- an index, counting from 1- Returns:
- the i-th inactive index
-
-