public class CodomainChain
extends java.lang.Object
A lookup table is built by composing all maps (in the same order as their
contexts were enqueued) in a single transformation and then by applying this
map to each value in the codomain interval
[intervalStart, intervalEnd]
note that, in order to
compose the maps, this interval has to be both the domain and codomain of
each transformation. The LUT is re-built every time the definition of the
codomain interval or the state of the queue changes.
Contexts are privately owned (add
and
update
make copies) because we want to
exclude the possibility that a context's state can be modified after the
lookup table is built.
Constructor and Description |
---|
CodomainChain(int start,
int end)
Creates a new chain.
|
CodomainChain(int start,
int end,
java.util.List<CodomainMapContext> mapContexts)
Creates a new chain.
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(CodomainMapContext mapCtx)
Adds a map context to the chain.
|
java.util.List<CodomainMapContext> |
getContexts()
Returns a copy of the codomain context if any.
|
int |
getIntervalEnd()
Returns the upper bound of the codomain interval.
|
int |
getIntervalStart()
Returns the lower bound of the codomain interval.
|
boolean |
hasMapContext()
Returns
true if some transformations need to be applied,
false otherwise. |
void |
remove()
Removes all
CodomainMapContext s except the identity and resets
the interval. |
boolean |
remove(CodomainMapContext mapCtx)
Removes a map context from the chain.
|
void |
setInterval(int start,
int end)
Sets the codomain interval.
|
java.lang.String |
toString()
Overrides the toString method.
|
int |
transform(int x)
Applies the transformation.
|
void |
update(CodomainMapContext mapCtx)
Updates a map context in the chain.
|
public CodomainChain(int start, int end)
transform
method
returns the input value. The interval defined by start
and
end
must be a sub-interval of
[QuantumStrategy.MIN
, QuantumStrategy.MAX
]
.start
- The lower bound of the codomain interval.end
- The upper bound of the codomain interval.public CodomainChain(int start, int end, java.util.List<CodomainMapContext> mapContexts)
mapContexts
is null
or empty, the chain
will contain only the identity context. The interval defined by
start
and end
has to be a sub-interval of
[QuantumStrategy.MIN
, QuantumStrategy.MAX
]
.start
- The lower bound of the codomain interval.end
- The upper bound of the codomain interval.mapContexts
- The sequence of CodomainMapContext
objects that define
the chain. No two objects of the same class are allowed. The
objects in this list are copied.java.lang.IllegalArgumentException
- If one of the contexts is already defined.public void setInterval(int start, int end)
start
and end
must be a sub-interval of
[QuantumStrategy.MIN
, QuantumStrategy.MAX
]
.start
- The lower bound of the codomain interval.end
- The upper bound of the codomain interval.public int getIntervalEnd()
public int getIntervalStart()
public void remove()
CodomainMapContext
s except the identity and resets
the interval.public boolean add(CodomainMapContext mapCtx)
mapCtx
. This is
because we don't want to compose the same transformation twice. This
method adds a copy of mapCtx
to the chain. This is because
we want to exclude the possibility that the context's state can be
modified after the lookup table is built. This method triggers a re-build
of the lookup table.mapCtx
- The context to add. Mustn't be null
.true
if the context was added,
false
otherwise.public void update(CodomainMapContext mapCtx)
mapCtx
.
This method replaces the old context with a copy of mapCtx
.
This is because we want to exclude the possibility that the context's
state can be modified after the lookup table is built. This method
triggers a re-build of the lookup table.mapCtx
- The context to add. Mustn't be null
and already
contained in the chain.java.lang.IllegalArgumentException
- If the specified context doesn't exist.public boolean remove(CodomainMapContext mapCtx)
mapCtx
. This means that the transformation associated to
the passed context won't be applied. This method triggers a re-build of
the lookup table.mapCtx
- The context to remove.true
if the chain was removed,
false
otherwise.public int transform(int x)
x
- The input value. Must be in the current codomain interval.public boolean hasMapContext()
true
if some transformations need to be applied,
false
otherwise.public java.util.List<CodomainMapContext> getContexts()
public java.lang.String toString()
toString
in class java.lang.Object
Object.toString()
Version: 5.4.6-ice35-b87
Copyright © 2018 The University of Dundee & Open Microscopy Environment. All Rights Reserved.