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

LearnLib / automatalib / 13112058969

03 Feb 2025 11:04AM UTC coverage: 92.108%. Remained the same
13112058969

push

github

mtf90
cleanup generics of WordTests

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

86.49
/core/src/main/java/net/automatalib/automaton/fsa/impl/CompactDFA.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.fsa.impl;
17

18
import java.util.BitSet;
19

20
import net.automatalib.alphabet.Alphabet;
21
import net.automatalib.automaton.AutomatonCreator;
22
import net.automatalib.automaton.base.AbstractCompactSimpleDeterministic;
23
import net.automatalib.automaton.fsa.MutableDFA;
24

25
public class CompactDFA<I> extends AbstractCompactSimpleDeterministic<I, Boolean> implements MutableDFA<Integer, I> {
26

27
    private final BitSet acceptance;
28

29
    public CompactDFA(Alphabet<I> alphabet) {
30
        this(alphabet, DEFAULT_INIT_CAPACITY, DEFAULT_RESIZE_FACTOR);
2✔
31
    }
2✔
32

33
    public CompactDFA(Alphabet<I> alphabet, int stateCapacity) {
34
        this(alphabet, stateCapacity, DEFAULT_RESIZE_FACTOR);
2✔
35
    }
2✔
36

37
    public CompactDFA(Alphabet<I> alphabet, float resizeFactor) {
38
        this(alphabet, DEFAULT_INIT_CAPACITY, resizeFactor);
×
39
    }
×
40

41
    public CompactDFA(Alphabet<I> alphabet, int stateCapacity, float resizeFactor) {
42
        super(alphabet, stateCapacity, resizeFactor);
2✔
43
        this.acceptance = new BitSet();
2✔
44
    }
2✔
45

46
    public CompactDFA(CompactDFA<I> other) {
47
        this(other.getInputAlphabet(), other);
1✔
48
    }
1✔
49

50
    protected CompactDFA(Alphabet<I> alphabet, CompactDFA<?> other) {
51
        super(alphabet, other);
2✔
52
        this.acceptance = (BitSet) other.acceptance.clone();
2✔
53
    }
2✔
54

55
    public <I2> CompactDFA<I2> translate(Alphabet<I2> newAlphabet) {
56
        if (newAlphabet.size() != numInputs()) {
2✔
57
            throw new IllegalArgumentException(
×
58
                    "Alphabet sizes must match, but they do not (old/new): " + numInputs() + " vs. " +
×
59
                    newAlphabet.size());
×
60
        }
61
        return new CompactDFA<>(newAlphabet, this);
2✔
62
    }
63

64
    @Override
65
    public void flipAcceptance() {
66
        acceptance.flip(0, size());
1✔
67
    }
1✔
68

69
    @Override
70
    public void setAccepting(Integer state, boolean accepting) {
71
        setAccepting(state.intValue(), accepting);
1✔
72
    }
1✔
73

74
    public void setAccepting(int state, boolean accepting) {
75
        acceptance.set(state, accepting);
2✔
76
    }
2✔
77

78
    @Override
79
    public Integer addState(boolean accepting) {
80
        return addState(Boolean.valueOf(accepting));
2✔
81
    }
82

83
    @Override
84
    public void clear() {
85
        acceptance.clear();
2✔
86
        super.clear();
2✔
87
    }
2✔
88

89
    @Override
90
    public void setStateProperty(int stateId, Boolean property) {
91
        setAccepting(stateId, property.booleanValue());
2✔
92
    }
2✔
93

94
    @Override
95
    public Boolean getStateProperty(int stateId) {
96
        return isAccepting(stateId);
2✔
97
    }
98

99
    public boolean isAccepting(int stateId) {
100
        return acceptance.get(stateId);
2✔
101
    }
102

103
    @Override
104
    public boolean isAccepting(Integer state) {
105
        return isAccepting(state.intValue());
2✔
106
    }
107

108
    public static final class Creator<I> implements AutomatonCreator<CompactDFA<I>, I> {
2✔
109

110
        @Override
111
        public CompactDFA<I> createAutomaton(Alphabet<I> alphabet, int numStates) {
112
            return new CompactDFA<>(alphabet, numStates);
2✔
113
        }
114

115
        @Override
116
        public CompactDFA<I> createAutomaton(Alphabet<I> alphabet) {
117
            return new CompactDFA<>(alphabet);
1✔
118
        }
119
    }
120

121
}
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

© 2026 Coveralls, Inc