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

LearnLib / automatalib / 12650654883

07 Jan 2025 11:26AM UTC coverage: 91.569%. First build
12650654883

Pull #85

github

web-flow
Merge 2499df5ae into d156e0830
Pull Request #85: Update dependencies

192 of 217 new or added lines in 63 files covered. (88.48%)

16573 of 18099 relevant lines covered (91.57%)

1.69 hits per line

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

30.77
/commons/util/src/main/java/net/automatalib/common/util/array/ArrayStorage.java
1
/* Copyright (C) 2013-2024 TU Dortmund University
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.common.util.array;
17

18
import java.util.AbstractList;
19
import java.util.Arrays;
20
import java.util.Collection;
21
import java.util.RandomAccess;
22
import java.util.function.Supplier;
23

24
import org.checkerframework.checker.nullness.qual.Nullable;
25

26
/**
27
 * A thin wrapper around a simple {@code Object[]} array. Mainly used (and useful) for heavily generic and array-based
28
 * data storage. Extends/Implements some convenient classes/interfaces.
29
 *
30
 * @param <T>
31
 *         the type of stored elements
32
 */
33
public final class ArrayStorage<T> extends AbstractList<T> implements RandomAccess {
34

35
    private final @Nullable Object[] storage;
36

37
    public ArrayStorage(int size) {
1✔
38
        this.storage = new Object[size];
1✔
39
    }
1✔
40

41
    public ArrayStorage(int size, Supplier<T> supplier) {
×
42
        this.storage = new Object[size];
×
43
        for (int i = 0; i < size; i++) {
×
44
            storage[i] = supplier.get();
×
45
        }
46
    }
×
47

48
    public ArrayStorage(Collection<? extends T> collection) {
NEW
49
        this(collection.toArray());
×
50
    }
×
51

52
    private ArrayStorage(@Nullable Object[] storage) {
×
53
        this.storage = storage;
×
54
    }
×
55

56
    @Override
57
    @SuppressWarnings("unchecked")
58
    public T get(int index) {
59
        return (T) storage[index];
1✔
60
    }
61

62
    @Override
63
    public T set(int index, T element) {
64
        final T oldValue = get(index);
1✔
65
        storage[index] = element;
1✔
66
        return oldValue;
1✔
67
    }
68

69
    @Override
70
    public int size() {
71
        return storage.length;
1✔
72
    }
73

74
    @Override
75
    public Object[] toArray() {
NEW
76
        return storage.clone();
×
77
    }
78

79
    @Override
80
    public boolean equals(@Nullable Object o) {
81
        if (this == o) {
×
82
            return true;
×
83
        }
84
        if (!(o instanceof ArrayStorage)) {
×
85
            return false;
×
86
        }
87

88
        final ArrayStorage<?> that = (ArrayStorage<?>) o;
×
89
        return Arrays.equals(storage, that.storage);
×
90
    }
91

92
    @Override
93
    public int hashCode() {
94
        return Arrays.hashCode(storage);
×
95
    }
96
}
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