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

LearnLib / learnlib / 6433387082

06 Oct 2023 03:10PM UTC coverage: 92.296% (-0.007%) from 92.303%
6433387082

push

github

mtf90
update Falk's developer id

11573 of 12539 relevant lines covered (92.3%)

1.67 hits per line

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

95.12
/algorithms/active/ttt/src/main/java/de/learnlib/algorithms/ttt/base/TTTTransition.java
1
/* Copyright (C) 2013-2023 TU Dortmund
2
 * This file is part of LearnLib, http://www.learnlib.de/.
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 de.learnlib.algorithms.ttt.base;
17

18
import de.learnlib.api.AccessSequenceProvider;
19
import de.learnlib.datastructure.list.IntrusiveListElem;
20
import de.learnlib.datastructure.list.IntrusiveListElemImpl;
21
import net.automatalib.words.Word;
22
import net.automatalib.words.WordBuilder;
23

24
/**
25
 * A transition in a {@link AbstractTTTHypothesis}.
26
 *
27
 * @param <I>
28
 *         input symbol type
29
 */
30
public class TTTTransition<I, D> extends IntrusiveListElemImpl<TTTTransition<I, D>>
2✔
31
        implements AccessSequenceProvider<I> {
32

33
    private final TTTState<I, D> source;
34
    private final I input;
35
    protected IntrusiveListElem<TTTTransition<I, D>> prevIncoming;
36
    // NON-TREE TRANSITION
37
    AbstractBaseDTNode<I, D> nonTreeTarget;
38
    // TREE TRANSITION
39
    private TTTState<I, D> treeTarget;
40

41
    public TTTTransition(TTTState<I, D> source, I input) {
2✔
42
        this.source = source;
2✔
43
        this.input = input;
2✔
44
    }
2✔
45

46
    public TTTState<I, D> getTreeTarget() {
47
        assert isTree();
2✔
48

49
        return treeTarget;
2✔
50
    }
51

52
    public boolean isTree() {
53
        return treeTarget != null;
2✔
54
    }
55

56
    public AbstractBaseDTNode<I, D> getNonTreeTarget() {
57
        assert !isTree();
2✔
58

59
        return nonTreeTarget;
2✔
60
    }
61

62
    void setNonTreeTarget(AbstractBaseDTNode<I, D> nonTreeTarget) {
63
        this.nonTreeTarget = nonTreeTarget;
2✔
64
        nonTreeTarget.getIncoming().insertIncoming(this);
2✔
65
    }
2✔
66

67
    public AbstractBaseDTNode<I, D> getDTTarget() {
68
        if (treeTarget != null) {
2✔
69
            return treeTarget.dtLeaf;
2✔
70
        }
71
        return nonTreeTarget;
2✔
72
    }
73

74
    public TTTState<I, D> getTarget() {
75
        if (treeTarget != null) {
2✔
76
            return treeTarget;
2✔
77
        }
78

79
        assert nonTreeTarget.isLeaf() :
2✔
80
                "transition target is not a leaf, but is a " + (nonTreeTarget.isTemp() ? "temp" : "non-temp") +
×
81
                " node with discr" + nonTreeTarget.getDiscriminator();
×
82
        assert nonTreeTarget.getData() != null;
2✔
83
        return nonTreeTarget.getData();
2✔
84
    }
85

86
    public TTTState<I, D> getSource() {
87
        return source;
2✔
88
    }
89

90
    public I getInput() {
91
        return input;
2✔
92
    }
93

94
    protected Object getProperty() {
95
        return null;
2✔
96
    }
97

98
    @Override
99
    public Word<I> getAccessSequence() {
100
        WordBuilder<I> wb = new WordBuilder<>(); // FIXME capacity hint
2✔
101

102
        TTTTransition<I, D> curr = this;
2✔
103

104
        while (curr != null) {
2✔
105
            wb.add(curr.input);
2✔
106
            curr = curr.source.getParentTransition();
2✔
107
        }
108

109
        return wb.reverse().toWord();
2✔
110
    }
111

112
    void makeTree(TTTState<I, D> treeTarget) {
113
        removeFromList();
2✔
114
        this.treeTarget = treeTarget;
2✔
115
        this.nonTreeTarget = null;
2✔
116
    }
2✔
117

118
    void removeFromList() {
119
        if (prevIncoming != null) {
2✔
120
            prevIncoming.setNextElement(next);
2✔
121
        }
122
        if (next != null) {
2✔
123
            next.prevIncoming = prevIncoming;
2✔
124
        }
125
    }
2✔
126
}
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