net.automatalib.words.Alphabet类的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(7.6k)|赞(0)|评价(0)|浏览(152)

本文整理了Java中net.automatalib.words.Alphabet类的一些代码示例,展示了Alphabet类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Alphabet类的具体详情如下:
包路径:net.automatalib.words.Alphabet
类名称: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

  1. private static <S, I> void fillTransitionProperties(UniversalDeterministicAutomaton<S, I, ?, ?, ?> automaton,
  2. Alphabet<I> alphabet,
  3. S state,
  4. Object[] properties) {
  5. int numInputs = alphabet.size();
  6. for (int i = 0; i < numInputs; i++) {
  7. I sym = alphabet.getSymbol(i);
  8. properties[i] = automaton.getTransitionProperty(state, sym);
  9. }
  10. }

代码示例来源:origin: net.automatalib/automata-api

  1. default <I2> Mapping<I2, I> translateFrom(Alphabet<I2> other) {
  2. if (other.size() > size()) {
  3. throw new IllegalArgumentException(
  4. "Cannot translate from an alphabet with " + other.size() + " elements into an alphabet with only " +
  5. size() + " elements");
  6. }
  7. return i -> getSymbol(other.getSymbolIndex(i));
  8. }

代码示例来源:origin: LearnLib/automatalib

  1. @Override
  2. public void addAlphabetSymbol(I symbol) throws GrowingAlphabetNotSupportedException {
  3. if (!this.inputAlphabet.containsSymbol(symbol)) {
  4. Alphabets.toGrowingAlphabetOrThrowException(this.inputAlphabet).addSymbol(symbol);
  5. }
  6. final int newAlphabetSize = this.inputAlphabet.size();
  7. // even if the symbol was already in the alphabet, we need to make sure to be able to store the new symbol
  8. if (alphabetSize < newAlphabetSize) {
  9. register.values().forEach(n -> n.ensureInputCapacity(newAlphabetSize));
  10. alphabetSize = newAlphabetSize;
  11. }
  12. }

代码示例来源:origin: net.automatalib/automata-core

  1. public AbstractCompactDeterministic(Alphabet<I> alphabet, int stateCapacity, float resizeFactor) {
  2. this.alphabet = alphabet;
  3. this.alphabetSize = alphabet.size();
  4. this.transitions = new Object[stateCapacity * alphabetSize];
  5. this.resizeFactor = resizeFactor;
  6. this.stateCapacity = stateCapacity;
  7. }

代码示例来源:origin: net.automatalib/automata-api

  1. @Override
  2. default int applyAsInt(I symbol) {
  3. return getSymbolIndex(symbol);
  4. }

代码示例来源:origin: de.learnlib/learnlib-lstar

  1. /**
  2. * Analyzes an inconsistency. This analysis consists in determining the column in which the two successor rows
  3. * differ.
  4. *
  5. * @param incons
  6. * the inconsistency description
  7. *
  8. * @return the suffix to add in order to fix the inconsistency
  9. */
  10. protected Word<I> analyzeInconsistency(Inconsistency<I> incons) {
  11. int inputIdx = alphabet.getSymbolIndex(incons.getSymbol());
  12. Row<I> succRow1 = incons.getFirstRow().getSuccessor(inputIdx);
  13. Row<I> succRow2 = incons.getSecondRow().getSuccessor(inputIdx);
  14. int numSuffixes = table.getSuffixes().size();
  15. for (int i = 0; i < numSuffixes; i++) {
  16. D val1 = table.cellContents(succRow1, i), val2 = table.cellContents(succRow2, i);
  17. if (!Objects.equals(val1, val2)) {
  18. I sym = alphabet.getSymbol(inputIdx);
  19. Word<I> suffix = table.getSuffixes().get(i);
  20. return suffix.prepend(sym);
  21. }
  22. }
  23. throw new IllegalArgumentException("Bogus inconsistency");
  24. }

代码示例来源:origin: LearnLib/automatalib

  1. @Override
  2. default void writeToArray(int offset, Object[] array, int tgtOfs, int num) {
  3. for (int i = offset, j = tgtOfs, k = 0; k < num; i++, j++, k++) {
  4. array[j] = getSymbol(i);
  5. }
  6. }

代码示例来源:origin: net.automatalib/automata-core

  1. @Override
  2. public void addAlphabetSymbol(I symbol) {
  3. if (this.alphabet.containsSymbol(symbol)) {
  4. return;
  5. }
  6. final int oldAlphabetSize = this.alphabetSize;
  7. final int newAlphabetSize = oldAlphabetSize + 1;
  8. final int newArraySize = this.transitions.length + this.stateCapacity;
  9. final Object[] newTransitions = new Object[newArraySize];
  10. for (int i = 0; i < this.numStates; i++) {
  11. System.arraycopy(transitions, i * oldAlphabetSize, newTransitions, i * newAlphabetSize, oldAlphabetSize);
  12. }
  13. this.transitions = newTransitions;
  14. this.alphabet = Alphabets.withNewSymbol(this.alphabet, symbol);
  15. this.alphabetSize = newAlphabetSize;
  16. }

代码示例来源:origin: LearnLib/automatalib

  1. final boolean deadlocks = result.getInputAlphabet().stream().noneMatch(
  2. i -> result.getSuccessor(state, i) != null);
  3. result.setAccepting(state, deadlocks);

代码示例来源:origin: LearnLib/automatalib

  1. @Override
  2. public void addAlphabetSymbol(I symbol) throws GrowingAlphabetNotSupportedException {
  3. if (!this.inputAlphabet.containsSymbol(symbol)) {
  4. Alphabets.toGrowingAlphabetOrThrowException(this.inputAlphabet).addSymbol(symbol);
  5. }
  6. final int newAlphabetSize = this.inputAlphabet.size();
  7. // even if the symbol was already in the alphabet, we need to make sure to be able to store the new symbol
  8. if (alphabetSize < newAlphabetSize) {
  9. register.values().forEach(n -> n.ensureInputCapacity(newAlphabetSize));
  10. alphabetSize = newAlphabetSize;
  11. }
  12. }

代码示例来源:origin: net.automatalib/automata-core

  1. public AbstractCompactSimpleDet(Alphabet<I> alphabet, int stateCapacity, float resizeFactor) {
  2. this.alphabet = alphabet;
  3. this.alphabetSize = alphabet.size();
  4. this.transitions = new int[stateCapacity * alphabetSize];
  5. Arrays.fill(this.transitions, 0, this.transitions.length, INVALID_STATE);
  6. this.resizeFactor = resizeFactor;
  7. this.stateCapacity = stateCapacity;
  8. }

代码示例来源:origin: LearnLib/automatalib

  1. @Override
  2. default int compare(I o1, I o2) {
  3. return getSymbolIndex(o1) - getSymbolIndex(o2);
  4. }

代码示例来源:origin: net.automatalib/automata-api

  1. @Override
  2. default void writeToArray(int offset, Object[] array, int tgtOfs, int num) {
  3. for (int i = offset, j = tgtOfs, k = 0; k < num; i++, j++, k++) {
  4. array[j] = getSymbol(i);
  5. }
  6. }

代码示例来源:origin: net.automatalib/automata-core

  1. @Override
  2. public void addAlphabetSymbol(I symbol) {
  3. if (this.alphabet.containsSymbol(symbol)) {
  4. return;
  5. }
  6. final int oldAlphabetSize = this.alphabetSize;
  7. final int newAlphabetSize = oldAlphabetSize + 1;
  8. final int newArraySize = this.transitions.length + this.stateCapacity;
  9. final int[] newTransitions = new int[newArraySize];
  10. Arrays.fill(newTransitions, 0, newArraySize, INVALID_STATE);
  11. for (int i = 0; i < this.numStates; i++) {
  12. System.arraycopy(transitions, i * oldAlphabetSize, newTransitions, i * newAlphabetSize, oldAlphabetSize);
  13. }
  14. this.transitions = newTransitions;
  15. this.alphabet = Alphabets.withNewSymbol(this.alphabet, symbol);
  16. this.alphabetSize = newAlphabetSize;
  17. }

代码示例来源:origin: LearnLib/automatalib

  1. private static <S, I> void fillTransitionProperties(UniversalDeterministicAutomaton<S, I, ?, ?, ?> automaton,
  2. Alphabet<I> alphabet,
  3. S state,
  4. Object[] properties) {
  5. int numInputs = alphabet.size();
  6. for (int i = 0; i < numInputs; i++) {
  7. I sym = alphabet.getSymbol(i);
  8. properties[i] = automaton.getTransitionProperty(state, sym);
  9. }
  10. }

代码示例来源:origin: net.automatalib/automata-core

  1. @Override
  2. public void addAlphabetSymbol(I symbol) {
  3. if (this.inputAlphabet.containsSymbol(symbol)) {
  4. return;
  5. }
  6. this.inputAlphabet = Alphabets.withNewSymbol(this.inputAlphabet, symbol);
  7. final int newAlphabetSize = this.inputAlphabet.size();
  8. for (final S s : this.getStates()) {
  9. s.ensureInputCapacity(newAlphabetSize);
  10. }
  11. }

代码示例来源:origin: LearnLib/automatalib

  1. default <I2> Mapping<I2, I> translateFrom(Alphabet<I2> other) {
  2. if (other.size() > size()) {
  3. throw new IllegalArgumentException(
  4. "Cannot translate from an alphabet with " + other.size() + " elements into an alphabet with only " +
  5. size() + " elements");
  6. }
  7. return i -> getSymbol(other.getSymbolIndex(i));
  8. }

代码示例来源:origin: net.automatalib/automata-core

  1. @SuppressWarnings("unchecked")
  2. public AbstractCompactSimpleNondet(Alphabet<I> alphabet, int stateCapacity, float resizeFactor) {
  3. this.alphabet = alphabet;
  4. this.alphabetSize = alphabet.size();
  5. //this.transitions = new TIntSet[stateCapacity * alphabetSize];
  6. this.transitions = new Set[stateCapacity * alphabetSize]; // TODO: replace by primitive specialization
  7. this.resizeFactor = resizeFactor;
  8. this.stateCapacity = stateCapacity;
  9. //this.initial = new TIntHashSet();
  10. this.initial = new HashSet<>(); // TODO: replace by primitive specialization
  11. }

代码示例来源:origin: net.automatalib/automata-api

  1. @Override
  2. default int compare(I o1, I o2) {
  3. return getSymbolIndex(o1) - getSymbolIndex(o2);
  4. }

代码示例来源:origin: net.automatalib/automata-api

  1. @Override
  2. default I apply(int index) {
  3. return getSymbol(index);
  4. }

相关文章