本文整理了Java中net.automatalib.words.Alphabet
类的一些代码示例,展示了Alphabet
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Alphabet
类的具体详情如下:
包路径:net.automatalib.words.Alphabet
类名称:Alphabet
[英]Class implementing an (indexed) alphabet. An alphabet is a collection of symbols, where each symbol has a (unique) index. Apart from serving as a collection, this class also provides a one-to-one mapping between symbols and indices.
[中]实现(索引)字母表的类。字母表是符号的集合,其中每个符号都有一个(唯一的)索引。除了用作集合之外,此类还提供符号和索引之间的一对一映射。
代码示例来源:origin: net.automatalib/automata-util
private static <S, I> void fillTransitionProperties(UniversalDeterministicAutomaton<S, I, ?, ?, ?> automaton,
Alphabet<I> alphabet,
S state,
Object[] properties) {
int numInputs = alphabet.size();
for (int i = 0; i < numInputs; i++) {
I sym = alphabet.getSymbol(i);
properties[i] = automaton.getTransitionProperty(state, sym);
}
}
代码示例来源:origin: net.automatalib/automata-api
default <I2> Mapping<I2, I> translateFrom(Alphabet<I2> other) {
if (other.size() > size()) {
throw new IllegalArgumentException(
"Cannot translate from an alphabet with " + other.size() + " elements into an alphabet with only " +
size() + " elements");
}
return i -> getSymbol(other.getSymbolIndex(i));
}
代码示例来源:origin: LearnLib/automatalib
@Override
public void addAlphabetSymbol(I symbol) throws GrowingAlphabetNotSupportedException {
if (!this.inputAlphabet.containsSymbol(symbol)) {
Alphabets.toGrowingAlphabetOrThrowException(this.inputAlphabet).addSymbol(symbol);
}
final int newAlphabetSize = this.inputAlphabet.size();
// even if the symbol was already in the alphabet, we need to make sure to be able to store the new symbol
if (alphabetSize < newAlphabetSize) {
register.values().forEach(n -> n.ensureInputCapacity(newAlphabetSize));
alphabetSize = newAlphabetSize;
}
}
代码示例来源:origin: net.automatalib/automata-core
public AbstractCompactDeterministic(Alphabet<I> alphabet, int stateCapacity, float resizeFactor) {
this.alphabet = alphabet;
this.alphabetSize = alphabet.size();
this.transitions = new Object[stateCapacity * alphabetSize];
this.resizeFactor = resizeFactor;
this.stateCapacity = stateCapacity;
}
代码示例来源:origin: net.automatalib/automata-api
@Override
default int applyAsInt(I symbol) {
return getSymbolIndex(symbol);
}
代码示例来源:origin: de.learnlib/learnlib-lstar
/**
* Analyzes an inconsistency. This analysis consists in determining the column in which the two successor rows
* differ.
*
* @param incons
* the inconsistency description
*
* @return the suffix to add in order to fix the inconsistency
*/
protected Word<I> analyzeInconsistency(Inconsistency<I> incons) {
int inputIdx = alphabet.getSymbolIndex(incons.getSymbol());
Row<I> succRow1 = incons.getFirstRow().getSuccessor(inputIdx);
Row<I> succRow2 = incons.getSecondRow().getSuccessor(inputIdx);
int numSuffixes = table.getSuffixes().size();
for (int i = 0; i < numSuffixes; i++) {
D val1 = table.cellContents(succRow1, i), val2 = table.cellContents(succRow2, i);
if (!Objects.equals(val1, val2)) {
I sym = alphabet.getSymbol(inputIdx);
Word<I> suffix = table.getSuffixes().get(i);
return suffix.prepend(sym);
}
}
throw new IllegalArgumentException("Bogus inconsistency");
}
代码示例来源:origin: LearnLib/automatalib
@Override
default void writeToArray(int offset, Object[] array, int tgtOfs, int num) {
for (int i = offset, j = tgtOfs, k = 0; k < num; i++, j++, k++) {
array[j] = getSymbol(i);
}
}
代码示例来源:origin: net.automatalib/automata-core
@Override
public void addAlphabetSymbol(I symbol) {
if (this.alphabet.containsSymbol(symbol)) {
return;
}
final int oldAlphabetSize = this.alphabetSize;
final int newAlphabetSize = oldAlphabetSize + 1;
final int newArraySize = this.transitions.length + this.stateCapacity;
final Object[] newTransitions = new Object[newArraySize];
for (int i = 0; i < this.numStates; i++) {
System.arraycopy(transitions, i * oldAlphabetSize, newTransitions, i * newAlphabetSize, oldAlphabetSize);
}
this.transitions = newTransitions;
this.alphabet = Alphabets.withNewSymbol(this.alphabet, symbol);
this.alphabetSize = newAlphabetSize;
}
代码示例来源:origin: LearnLib/automatalib
final boolean deadlocks = result.getInputAlphabet().stream().noneMatch(
i -> result.getSuccessor(state, i) != null);
result.setAccepting(state, deadlocks);
代码示例来源:origin: LearnLib/automatalib
@Override
public void addAlphabetSymbol(I symbol) throws GrowingAlphabetNotSupportedException {
if (!this.inputAlphabet.containsSymbol(symbol)) {
Alphabets.toGrowingAlphabetOrThrowException(this.inputAlphabet).addSymbol(symbol);
}
final int newAlphabetSize = this.inputAlphabet.size();
// even if the symbol was already in the alphabet, we need to make sure to be able to store the new symbol
if (alphabetSize < newAlphabetSize) {
register.values().forEach(n -> n.ensureInputCapacity(newAlphabetSize));
alphabetSize = newAlphabetSize;
}
}
代码示例来源:origin: net.automatalib/automata-core
public AbstractCompactSimpleDet(Alphabet<I> alphabet, int stateCapacity, float resizeFactor) {
this.alphabet = alphabet;
this.alphabetSize = alphabet.size();
this.transitions = new int[stateCapacity * alphabetSize];
Arrays.fill(this.transitions, 0, this.transitions.length, INVALID_STATE);
this.resizeFactor = resizeFactor;
this.stateCapacity = stateCapacity;
}
代码示例来源:origin: LearnLib/automatalib
@Override
default int compare(I o1, I o2) {
return getSymbolIndex(o1) - getSymbolIndex(o2);
}
代码示例来源:origin: net.automatalib/automata-api
@Override
default void writeToArray(int offset, Object[] array, int tgtOfs, int num) {
for (int i = offset, j = tgtOfs, k = 0; k < num; i++, j++, k++) {
array[j] = getSymbol(i);
}
}
代码示例来源:origin: net.automatalib/automata-core
@Override
public void addAlphabetSymbol(I symbol) {
if (this.alphabet.containsSymbol(symbol)) {
return;
}
final int oldAlphabetSize = this.alphabetSize;
final int newAlphabetSize = oldAlphabetSize + 1;
final int newArraySize = this.transitions.length + this.stateCapacity;
final int[] newTransitions = new int[newArraySize];
Arrays.fill(newTransitions, 0, newArraySize, INVALID_STATE);
for (int i = 0; i < this.numStates; i++) {
System.arraycopy(transitions, i * oldAlphabetSize, newTransitions, i * newAlphabetSize, oldAlphabetSize);
}
this.transitions = newTransitions;
this.alphabet = Alphabets.withNewSymbol(this.alphabet, symbol);
this.alphabetSize = newAlphabetSize;
}
代码示例来源:origin: LearnLib/automatalib
private static <S, I> void fillTransitionProperties(UniversalDeterministicAutomaton<S, I, ?, ?, ?> automaton,
Alphabet<I> alphabet,
S state,
Object[] properties) {
int numInputs = alphabet.size();
for (int i = 0; i < numInputs; i++) {
I sym = alphabet.getSymbol(i);
properties[i] = automaton.getTransitionProperty(state, sym);
}
}
代码示例来源:origin: net.automatalib/automata-core
@Override
public void addAlphabetSymbol(I symbol) {
if (this.inputAlphabet.containsSymbol(symbol)) {
return;
}
this.inputAlphabet = Alphabets.withNewSymbol(this.inputAlphabet, symbol);
final int newAlphabetSize = this.inputAlphabet.size();
for (final S s : this.getStates()) {
s.ensureInputCapacity(newAlphabetSize);
}
}
代码示例来源:origin: LearnLib/automatalib
default <I2> Mapping<I2, I> translateFrom(Alphabet<I2> other) {
if (other.size() > size()) {
throw new IllegalArgumentException(
"Cannot translate from an alphabet with " + other.size() + " elements into an alphabet with only " +
size() + " elements");
}
return i -> getSymbol(other.getSymbolIndex(i));
}
代码示例来源:origin: net.automatalib/automata-core
@SuppressWarnings("unchecked")
public AbstractCompactSimpleNondet(Alphabet<I> alphabet, int stateCapacity, float resizeFactor) {
this.alphabet = alphabet;
this.alphabetSize = alphabet.size();
//this.transitions = new TIntSet[stateCapacity * alphabetSize];
this.transitions = new Set[stateCapacity * alphabetSize]; // TODO: replace by primitive specialization
this.resizeFactor = resizeFactor;
this.stateCapacity = stateCapacity;
//this.initial = new TIntHashSet();
this.initial = new HashSet<>(); // TODO: replace by primitive specialization
}
代码示例来源:origin: net.automatalib/automata-api
@Override
default int compare(I o1, I o2) {
return getSymbolIndex(o1) - getSymbolIndex(o2);
}
代码示例来源:origin: net.automatalib/automata-api
@Override
default I apply(int index) {
return getSymbol(index);
}
内容来源于网络,如有侵权,请联系作者删除!