blob: 8a5ae84c3849cd90bd211f7c616a8535958bd759 [file] [log] [blame]
Jian Lifc5ca932015-12-10 12:11:57 -08001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
Jian Lifc5ca932015-12-10 12:11:57 -08003 *
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 */
16package org.onosproject.store.service;
17
18/**
19 * Transactional Set data structure.
20 * <p>
21 * A TransactionalSet is implemented with the help of TransactionalMap data structure.
22 * All operations performed on this set within a transaction boundary are invisible externally
23 * until the point when the transaction commits. A commit usually succeeds in the absence of conflicts.
24 *
25 * @param <E> type of element.
26 */
27public interface TransactionalSet<E> {
28
29 /**
30 * Adds the specified element to this set if it is not already present
31 * (optional operation). More formally, adds the specified element
32 * <tt>e</tt> to this set if the set contains no element <tt>e2</tt>
33 * such that
34 * <tt>(e==null&nbsp;?&nbsp;e2==null&nbsp;:&nbsp;e.equals(e2))</tt>.
35 * If this set already contains the element, the call leaves the set
36 * unchanged and returns <tt>false</tt>. In combination with the
37 * restriction on constructors, this ensures that sets never contain
38 * duplicate elements.
39 *
40 * @param e element to be added to this set
41 * @return <tt>true</tt> if this set did not already contain the specified
42 * element
43 */
44 boolean add(E e);
45
46 /**
47 * Removes the specified element from this set if it is present
48 * (optional operation). More formally, removes an element <tt>e</tt>
49 * such that
50 * <tt>(o==null&nbsp;?&nbsp;e==null&nbsp;:&nbsp;o.equals(e))</tt>, if
51 * this set contains such an element. Returns <tt>true</tt> if this set
52 * contained the element (or equivalently, if this set changed as a
53 * result of the call). (This set will not contain the element once the
54 * call returns.)
55 *
56 * @param e element to be removed to this set
57 * @return <tt>true</tt> if this set contained the specified element
58 */
59 boolean remove(E e);
60
61 /**
62 * Returns <tt>true</tt> if this set contains the specified element.
63 * More formally, returns <tt>true</tt> if and only if this set
64 * contains an element <tt>e</tt> such that
65 * <tt>(o==null&nbsp;?&nbsp;e==null&nbsp;:&nbsp;o.equals(e))</tt>.
66 *
67 * @param e element whose presence in this set is to be tested
68 * @return <tt>true</tt> if this set contains the specified element
69 * @throws ClassCastException if the type of the specified element
70 * is incompatible with this set
71 * @throws NullPointerException if the specified element is null and this
72 * set does not permit null elements
73 */
74 boolean contains(E e);
75}