@PublicEvolving public final class InputSelection extends Object implements Serializable
Modifier and Type | Class and Description |
---|---|
static class |
InputSelection.Builder
Utility class for creating
InputSelection . |
Modifier and Type | Field and Description |
---|---|
static InputSelection |
ALL
The
InputSelection instance which indicates to select all inputs. |
static InputSelection |
FIRST
The
InputSelection instance which indicates to select the first input. |
static int |
NONE_AVAILABLE |
static InputSelection |
SECOND
The
InputSelection instance which indicates to select the second input. |
Modifier and Type | Method and Description |
---|---|
boolean |
areAllInputsSelected()
Tests if all inputs are selected.
|
boolean |
equals(Object o) |
int |
fairSelectNextIndex(long availableInputsMask,
int lastReadInputIndex)
Fairly select one of the available inputs for reading.
|
static int |
fairSelectNextIndex(long inputMask,
long availableInputsMask,
int lastReadInputIndex)
Fairly select one of the available inputs for reading.
|
int |
fairSelectNextIndexOutOf2(int availableInputsMask,
int lastReadInputIndex)
Fairly select one of the two inputs for reading.
|
static int |
fairSelectNextIndexOutOf2(int selectionMask,
int availableInputsMask,
int lastReadInputIndex)
Fairly select one of the two inputs for reading.
|
long |
getInputMask() |
boolean |
isInputSelected(int inputId)
Tests if the input specified by
inputId is selected. |
String |
toString() |
public static final int NONE_AVAILABLE
public static final InputSelection ALL
InputSelection
instance which indicates to select all inputs.public static final InputSelection FIRST
InputSelection
instance which indicates to select the first input.public static final InputSelection SECOND
InputSelection
instance which indicates to select the second input.public long getInputMask()
public boolean isInputSelected(int inputId)
inputId
is selected.inputId
- The input id, see the description of inputId
in InputSelection.Builder.select(int)
.true
if the input is selected, false
otherwise.public boolean areAllInputsSelected()
true
if the input mask equals -1, false
otherwise.public int fairSelectNextIndexOutOf2(int availableInputsMask, int lastReadInputIndex)
inputMask
includes two inputs
and both inputs are available, alternately select one of them. Otherwise, select the
available one of inputMask
, or return NONE_AVAILABLE
to
indicate no input is selected.
Note that this supports only two inputs for performance reasons.
availableInputsMask
- The mask of all available inputs.lastReadInputIndex
- The index of last read input.NONE_AVAILABLE
(if
inputMask
is empty or the inputs in inputMask
are unavailable).public static int fairSelectNextIndexOutOf2(int selectionMask, int availableInputsMask, int lastReadInputIndex)
inputMask
includes two inputs
and both inputs are available, alternately select one of them. Otherwise, select the
available one of inputMask
, or return NONE_AVAILABLE
to
indicate no input is selected.
Note that this supports only two inputs for performance reasons.
selectionMask
- The mask of inputs that are selected. Note -1 for this is interpreted as
all of the 32 inputs are available.availableInputsMask
- The mask of all available inputs.lastReadInputIndex
- The index of last read input.NONE_AVAILABLE
(if
inputMask
is empty or the inputs in inputMask
are unavailable).public int fairSelectNextIndex(long availableInputsMask, int lastReadInputIndex)
availableInputsMask
- The mask of all available inputs. Note -1 for this is interpreted
as all of the 32 inputs are available.lastReadInputIndex
- The index of last read input.NONE_AVAILABLE
(if
inputMask
is empty or the inputs in inputMask
are unavailable).public static int fairSelectNextIndex(long inputMask, long availableInputsMask, int lastReadInputIndex)
inputMask
- The mask of inputs that are selected. Note -1 for this is interpreted as all
of the 32 inputs are available.availableInputsMask
- The mask of all available inputs. Note -1 for this is interpreted
as all of the 32 inputs are available.lastReadInputIndex
- The index of last read input.NONE_AVAILABLE
(if
inputMask
is empty or the inputs in inputMask
are unavailable).Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.