• 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

95.24
/incremental/src/main/java/net/automatalib/incremental/dfa/dag/State.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.incremental.dfa.dag;
17

18
import net.automatalib.incremental.dfa.Acceptance;
19

20
/**
21
 * State data structure. Note that states are generally unique throughout the algorithm, hence comparisons are always
22
 * identity comparisons.
23
 */
24
final class State {
25

26
    static final State SINK = new State(new StateSignature(0, Acceptance.FALSE));
2✔
27

28
    private final StateSignature signature;
29
    private int numIncoming;
30

31
    /**
32
     * Constructor. Initializes the state with a given signature.
33
     *
34
     * @param signature
35
     *         the signature
36
     */
37
    State(StateSignature signature) {
2✔
38
        this.signature = signature;
2✔
39
        this.numIncoming = 0;
2✔
40
    }
2✔
41

42
    /**
43
     * Increases the number of incoming transitions.
44
     */
45
    void increaseIncoming() {
46
        numIncoming++;
2✔
47
    }
2✔
48

49
    /**
50
     * Decreases the number of incoming transitions.
51
     */
52
    void decreaseIncoming() {
53
        numIncoming--;
2✔
54
    }
2✔
55

56
    /**
57
     * Checks whether this node is a confluence node (i.e. has more than one incoming transitions).
58
     *
59
     * @return {@code true} if this node is a confluence node, {@code false} otherwise.
60
     */
61
    boolean isConfluence() {
62
        return numIncoming > 1;
2✔
63
    }
64

65
    /**
66
     * Retrieves the ternary acceptance status of this node.
67
     *
68
     * @return the acceptance status of this node.
69
     */
70
    Acceptance getAcceptance() {
71
        if (signature == null) {
2✔
72
            return Acceptance.FALSE;
×
73
        }
74
        return signature.acceptance;
2✔
75
    }
76

77
    /**
78
     * Retrieves the successor for the given input index.
79
     *
80
     * @param idx
81
     *         the input index
82
     *
83
     * @return the successor state for the given index
84
     */
85
    State getSuccessor(int idx) {
86
        return signature.successors.get(idx);
2✔
87
    }
88

89
    /**
90
     * Retrieves the signature of this state.
91
     *
92
     * @return the state's signature
93
     */
94
    StateSignature getSignature() {
95
        return signature;
2✔
96
    }
97

98
    @Override
99
    public String toString() {
100
        if (isSink()) {
2✔
101
            return "sink";
2✔
102
        }
103
        return "s";
2✔
104
    }
105

106
    boolean isSink() {
107
        return this == SINK;
2✔
108
    }
109

110
    void ensureInputCapacity(int capacity) {
111
        signature.successors.ensureCapacity(capacity);
2✔
112
    }
2✔
113
}
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