• 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

97.78
/algorithms/passive/ostia/src/main/java/de/learnlib/algorithms/ostia/IntQueue.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.ostia;
17

18
import java.util.HashSet;
19
import java.util.Set;
20
import java.util.StringJoiner;
21

22
import net.automatalib.commons.smartcollections.IntSeq;
23
import org.checkerframework.checker.nullness.qual.Nullable;
24
import org.checkerframework.checker.nullness.qual.PolyNull;
25

26
class IntQueue {
2✔
27

28
    int value;
29
    @Nullable IntQueue next;
30

31
    @Override
32
    public String toString() {
33
        final StringJoiner sj = new StringJoiner(", ", "[", "]");
2✔
34

35
        IntQueue iter = this;
2✔
36
        while (iter != null) {
2✔
37
            sj.add(Integer.toString(iter.value));
2✔
38
            iter = iter.next;
2✔
39
        }
40
        return sj.toString();
2✔
41
    }
42

43
    static @Nullable IntQueue asQueue(IntSeq str) {
44
        IntQueue q = null;
2✔
45
        for (int i = str.size() - 1; i >= 0; i--) {
2✔
46
            IntQueue next = new IntQueue();
2✔
47
            next.value = str.get(i);
2✔
48
            next.next = q;
2✔
49
            q = next;
2✔
50
        }
51
        assert !IntQueue.hasCycle(q);
2✔
52
        return q;
2✔
53
    }
54

55
    static boolean eq(@Nullable IntQueue a, @Nullable IntQueue b) {
56
        IntQueue aIter = a;
2✔
57
        IntQueue bIter = b;
2✔
58
        while (aIter != null && bIter != null) {
2✔
59
            if (aIter.value != bIter.value) {
2✔
60
                return false;
2✔
61
            }
62
            aIter = aIter.next;
2✔
63
            bIter = bIter.next;
2✔
64
        }
65
        return aIter == null && bIter == null;
2✔
66
    }
67

68
    static boolean hasCycle(@Nullable IntQueue q) {
69
        final Set<IntQueue> elements = new HashSet<>();
2✔
70
        IntQueue iter = q;
2✔
71
        while (iter != null) {
2✔
72
            if (!elements.add(iter)) {
2✔
73
                return true;
×
74
            }
75
            iter = iter.next;
2✔
76
        }
77
        return false;
2✔
78
    }
79

80
    static @PolyNull IntQueue copyAndConcat(@Nullable IntQueue q, @PolyNull IntQueue tail) {
81
        assert !hasCycle(q) && !hasCycle(tail);
2✔
82
        if (q == null) {
2✔
83
            return tail;
2✔
84
        }
85
        final IntQueue root = new IntQueue();
2✔
86
        root.value = q.value;
2✔
87
        IntQueue curr = root;
2✔
88
        IntQueue iter = q.next;
2✔
89
        while (iter != null) {
2✔
90
            curr.next = new IntQueue();
2✔
91
            curr = curr.next;
2✔
92
            curr.value = iter.value;
2✔
93
            iter = iter.next;
2✔
94
        }
95
        curr.next = tail;
2✔
96
        assert !hasCycle(root);
2✔
97
        return root;
2✔
98
    }
99
}
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