net.automatalib.words.Alphabet.containsSymbol()方法的使用及代码示例

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

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

Alphabet.containsSymbol介绍

[英]Checks whether the given symbol is part of the alphabet.

Caution: the default implementation is rather inefficient and should be overridden, if possible.
[中]检查给定符号是否为字母表的一部分。
警告:默认实现效率很低,如果可能,应该重写它。

代码示例

代码示例来源: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: 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: 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;
    @SuppressWarnings("unchecked")
    final Set<Integer>[] newTransitions = new Set[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: de.learnlib/learnlib-lstar

@Override
  public void addAlphabetSymbol(I symbol) {

    if (this.alphabet.containsSymbol(symbol)) {
      return;
    }

    final List<List<Row<I>>> unclosed = this.table.addAlphabetSymbol(symbol, oracle);

    // since we share the alphabet instance with our observation table, our alphabet might have already been updated
    // (if it was already a GrowableAlphabet)
    if (!this.alphabet.containsSymbol(symbol)) {
      this.alphabet = Alphabets.withNewSymbol(this.alphabet, symbol);
    }

    completeConsistentTable(unclosed, true);
  }
}

代码示例来源: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: 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: de.learnlib/learnlib-dhc

@Override
public void addAlphabetSymbol(I symbol) {
  if (this.alphabet.containsSymbol(symbol)) {
    return;
  }
  final Iterator<Word<I>> splitterIterator = this.splitters.iterator();
  final LinkedHashSet<Word<I>> newSplitters = Sets.newLinkedHashSetWithExpectedSize(this.splitters.size() + 1);
  // see initial initialization of the splitters
  for (int i = 0; i < this.alphabet.size(); i++) {
    newSplitters.add(splitterIterator.next());
  }
  newSplitters.add(Word.fromLetter(symbol));
  while (splitterIterator.hasNext()) {
    newSplitters.add(splitterIterator.next());
  }
  this.alphabet = Alphabets.withNewSymbol(this.alphabet, symbol);
  this.splitters = newSplitters;
  this.startLearning();
}

代码示例来源: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: de.learnlib/learnlib-discrimination-tree

@Override
public void addAlphabetSymbol(I symbol) {
  if (this.alphabet.containsSymbol(symbol)) {
    return;
  }
  this.alphabet = Alphabets.withNewSymbol(this.alphabet, symbol);
  final int alphabetSize = this.alphabet.size();
  for (final HState<I, O, SP, TP> s : this.getStates()) {
    s.ensureInputCapacity(alphabetSize);
  }
}

代码示例来源: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: de.learnlib/learnlib-discrimination-tree

@Override
public void addAlphabetSymbol(I symbol) {
  if (this.alphabet.containsSymbol(symbol)) {
    return;
  }
  final int newSymbolIdx = this.alphabet.size();
  this.hypothesis.addAlphabetSymbol(symbol);
  // since we share the alphabet instance with our hypothesis, our alphabet might have already been updated (if it
  // was already a GrowableAlphabet)
  if (!this.alphabet.containsSymbol(symbol)) {
    this.alphabet = Alphabets.withNewSymbol(this.alphabet, symbol);
  }
  for (final HState<I, D, SP, TP> s : this.hypothesis.getStates()) {
    final HTransition<I, D, SP, TP> newTrans = new HTransition<>(s, symbol, dtree.getRoot());
    s.setTransition(newSymbolIdx, newTrans);
    newTransitions.add(newTrans);
    openTransitions.add(newTrans);
  }
  this.updateHypothesis();
}

代码示例来源: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) {
    ensureInputCapacity(root, alphabetSize, newAlphabetSize);
    alphabetSize = newAlphabetSize;
  }
}

代码示例来源: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) {
    ensureInputCapacity(root, alphabetSize, newAlphabetSize);
    alphabetSize = newAlphabetSize;
  }
}

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

@Override
public void addAlphabetSymbol(I symbol) {
  if (alphabet.containsSymbol(symbol)) {
    return;
  }
  this.internalHyp.addAlphabetSymbol(symbol);
  SymbolHidingAlphabet.runWhileHiding(alphabet, symbol, () -> super.addAlphabetSymbol(symbol));
  this.updateInternalHypothesis();
}

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

@Override
public void addAlphabetSymbol(I symbol) {
  if (this.alphabet.containsSymbol(symbol)) {
    return;
  }
  this.alphabet = Alphabets.withNewSymbol(this.alphabet, symbol);
  final int alphabetSize = this.alphabet.size();
  for (final TTTState<I, D> s : this.getStates()) {
    s.ensureInputCapacity(alphabetSize);
  }
}

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

@Override
public final void addAlphabetSymbol(I symbol) throws GrowingAlphabetNotSupportedException {
  if (!this.alphabet.containsSymbol(symbol)) {
    Alphabets.toGrowingAlphabetOrThrowException(this.alphabet).addSymbol(symbol);
  }
  final int newAlphabetSize = this.alphabet.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) {
    updateTransitionStorage(Payload.of(alphabetSize,
                      newAlphabetSize,
                      numStates,
                      stateCapacity,
                      alphabetSize,
                      TransitionUpdateOperation.NEW_ALPHABET_SYMBOL));
    this.alphabetSize = newAlphabetSize;
  }
}

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

@Override
public void addAlphabetSymbol(I symbol) throws GrowingAlphabetNotSupportedException {
  if (!this.inputAlphabet.containsSymbol(symbol)) {
    Alphabets.toGrowingAlphabetOrThrowException(this.inputAlphabet).addSymbol(symbol);
  }
  // even if the symbol was already in the alphabet, we need to make sure to be able to store the new symbol
  final int newAlphabetSize = this.inputAlphabet.size();
  for (final S s : this.getStates()) {
    s.ensureInputCapacity(newAlphabetSize);
  }
}

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

@Override
public void addAlphabetSymbol(I symbol) {
  if (this.alphabet.containsSymbol(symbol)) {
    return;
  }
  this.hypothesis.addAlphabetSymbol(symbol);
  SymbolHidingAlphabet.runWhileHiding(alphabet,
                    symbol,
                    () -> this.observationTree.getObservationTree().addAlphabetSymbol(symbol));
  // since we share the alphabet instance with our hypothesis, our alphabet might have already been updated (if it
  // was already a GrowableAlphabet)
  if (!this.alphabet.containsSymbol(symbol)) {
    this.alphabet = Alphabets.withNewSymbol(this.alphabet, symbol);
  }
  for (final ADTState<I, O> s : this.hypothesis.getStates()) {
    this.openTransitions.add(this.hypothesis.createOpenTransition(s, symbol, this.adt.getRoot()));
  }
  this.closeTransitions();
}

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

List<String> invalidSymbols = new ArrayList<>();
for (String s : symbols) {
  if (!alphabet.containsSymbol(s)) {
    invalidSymbols.add(StringUtil.enquoteIfNecessary(s, ID_PATTERN));
    continue;

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

@Override
public void addAlphabetSymbol(I symbol) {
  if (this.alphabet.containsSymbol(symbol)) {
    return;
  }
  final int newSymbolIdx = this.alphabet.size();
  this.hypothesis.addAlphabetSymbol(symbol);
  // since we share the alphabet instance with our hypothesis, our alphabet might have already been updated (if it
  // was already a GrowableAlphabet)
  if (!this.alphabet.containsSymbol(symbol)) {
    this.alphabet = Alphabets.withNewSymbol(this.alphabet, symbol);
  }
  for (final TTTState<I, D> s : this.hypothesis.getStates()) {
    final TTTTransition<I, D> trans = createTransition(s, symbol);
    trans.setNonTreeTarget(dtree.getRoot());
    s.setTransition(newSymbolIdx, trans);
    openTransitions.insertIncoming(trans);
  }
  this.closeTransitions();
}

相关文章