$darkmode
DENOPTIM
SymmetricSet.java
Go to the documentation of this file.
1/*
2 * DENOPTIM
3 * Copyright (C) 2019 Vishwesh Venkatraman <vishwesh.venkatraman@ntnu.no> and
4 * Marco Foscato <marco.foscato@uib.no>
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Affero General Public License as published
8 * by the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Affero General Public License for more details.
15 *
16 * You should have received a copy of the GNU Affero General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20package denoptim.graph;
21
22import java.util.ArrayList;
23import java.util.Collection;
24
37// NB: keep it a List, not a Set: having the order helps comparison.
38
39public class SymmetricSet<T> extends ArrayList<T>
40{
41
45 private static final long serialVersionUID = 4L;
46
47//------------------------------------------------------------------------------
48
54 @Override
55 public boolean add(T item)
56 {
57 if (!contains(item))
58 {
59 return super.add(item);
60 } else {
61 return false;
62 }
63 }
64
65//------------------------------------------------------------------------------
66
67}
Class representing a list of references pointing to instances that are related by some conventional c...
static final long serialVersionUID
Version ID.
boolean add(T item)
Adds an item to this list, if not already present.