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

LearnLib / automatalib / 6763327895

05 Nov 2023 07:29PM UTC coverage: 89.726% (-0.1%) from 89.868%
6763327895

push

github

mtf90
fix typo

4 of 4 new or added lines in 4 files covered. (100.0%)

99 existing lines in 18 files now uncovered.

15677 of 17472 relevant lines covered (89.73%)

1.66 hits per line

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

0.0
/api/src/main/java/net/automatalib/graph/helper/SimpleNodeIDs.java
1
/* Copyright (C) 2013-2023 TU Dortmund
2
 * This file is part of AutomataLib, http://www.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.graph.helper;
17

18
import java.util.ArrayList;
19
import java.util.List;
20
import java.util.Map;
21

22
import com.google.common.collect.Maps;
23
import net.automatalib.graph.SimpleGraph;
24
import net.automatalib.graph.concept.NodeIDs;
25

26
public class SimpleNodeIDs<N> implements NodeIDs<N> {
27

28
    private final Map<N, Integer> nodeIds;
29
    private final List<N> nodes;
30

UNCOV
31
    public SimpleNodeIDs(SimpleGraph<N> graph) {
×
UNCOV
32
        this.nodes = new ArrayList<>(graph.getNodes());
×
UNCOV
33
        int numNodes = this.nodes.size();
×
UNCOV
34
        this.nodeIds = Maps.newHashMapWithExpectedSize(numNodes);
×
35

UNCOV
36
        for (int i = 0; i < numNodes; i++) {
×
UNCOV
37
            N node = this.nodes.get(i);
×
UNCOV
38
            nodeIds.put(node, i);
×
39
        }
UNCOV
40
    }
×
41

42
    @Override
43
    public int getNodeId(N node) {
UNCOV
44
        final Integer id = nodeIds.get(node);
×
45

UNCOV
46
        if (id == null) {
×
47
            throw new IllegalArgumentException();
×
48
        }
49

UNCOV
50
        return id;
×
51
    }
52

53
    @Override
54
    public N getNode(int id) {
55
        return nodes.get(id);
×
56
    }
57
}
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