• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

LearnLib / automatalib / 13138848026

04 Feb 2025 02:53PM UTC coverage: 92.108% (+2.2%) from 89.877%
13138848026

push

github

mtf90
[maven-release-plugin] prepare release automatalib-0.12.0

16609 of 18032 relevant lines covered (92.11%)

1.7 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

96.67
/core/src/main/java/net/automatalib/automaton/base/AbstractFastMutableNondet.java
1
/* Copyright (C) 2013-2025 TU Dortmund University
2
 * This file is part of AutomataLib <https://automatalib.net>.
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *     http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16
package net.automatalib.automaton.base;
17

18
import java.util.ArrayList;
19
import java.util.Collection;
20
import java.util.Collections;
21
import java.util.HashSet;
22
import java.util.List;
23
import java.util.Set;
24

25
import net.automatalib.alphabet.Alphabet;
26
import net.automatalib.ts.PowersetViewTS;
27
import net.automatalib.ts.powerset.impl.FastPowersetDTS;
28
import org.checkerframework.checker.nullness.qual.Nullable;
29

30
public abstract class AbstractFastMutableNondet<S extends AbstractFastState<Collection<T>>, I, T, SP, TP>
31
        extends AbstractFastMutable<S, I, T, SP, TP> {
32

33
    private final Set<S> initialStates = new HashSet<>();
2✔
34

35
    public AbstractFastMutableNondet(Alphabet<I> inputAlphabet) {
36
        super(inputAlphabet);
2✔
37
    }
2✔
38

39
    @Override
40
    public Set<S> getInitialStates() {
41
        return initialStates;
2✔
42
    }
43

44
    @Override
45
    public Collection<T> getTransitions(S state, I input) {
46
        int inputIdx = inputAlphabet.getSymbolIndex(input);
2✔
47
        final Collection<T> result = state.getTransitionObject(inputIdx);
2✔
48
        return result == null ? Collections.emptySet() : result;
2✔
49
    }
50

51
    @Override
52
    public void clear() {
53
        super.clear();
2✔
54
        initialStates.clear();
2✔
55
    }
2✔
56

57
    @Override
58
    public void setInitial(S state, boolean initial) {
59
        if (initial) {
2✔
60
            initialStates.add(state);
2✔
61
        } else {
62
            initialStates.remove(state);
2✔
63
        }
64
    }
2✔
65

66
    @Override
67
    public void setTransitions(S state, I input, Collection<? extends T> transitions) {
68
        int inputIdx = inputAlphabet.getSymbolIndex(input);
2✔
69
        state.setTransitionObject(inputIdx, new HashSet<>(transitions));
2✔
70
    }
2✔
71

72
    @Override
73
    public void removeState(S state, @Nullable S replacement) {
74
        super.removeState(state, replacement);
2✔
75

76
        if (initialStates.remove(state) && replacement != null) {
2✔
77
            initialStates.add(replacement);
2✔
78
        }
79
    }
2✔
80

81
    @Override
82
    public PowersetViewTS<Set<S>, I, ?, S, T> powersetView() {
83
        return new FastPowersetDTS<>(this);
×
84
    }
85

86
    @Override
87
    public Collection<I> getLocalInputs(S state) {
88
        final Alphabet<I> alphabet = getInputAlphabet();
2✔
89
        final int alphabetSize = alphabet.size();
2✔
90
        final List<I> result = new ArrayList<>(alphabetSize);
2✔
91

92
        for (int i = 0; i < alphabetSize; i++) {
2✔
93
            final Collection<T> trans = state.getTransitionObject(i);
2✔
94
            if (trans != null && !trans.isEmpty()) {
2✔
95
                result.add(alphabet.getSymbol(i));
2✔
96
            }
97
        }
98

99
        return result;
2✔
100
    }
101
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc