001    /*
002    Galois, a framework to exploit amorphous data-parallelism in irregular
003    programs.
004    
005    Copyright (C) 2010, The University of Texas at Austin. All rights reserved.
006    UNIVERSITY EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES CONCERNING THIS SOFTWARE
007    AND DOCUMENTATION, INCLUDING ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR ANY
008    PARTICULAR PURPOSE, NON-INFRINGEMENT AND WARRANTIES OF PERFORMANCE, AND ANY
009    WARRANTY THAT MIGHT OTHERWISE ARISE FROM COURSE OF DEALING OR USAGE OF TRADE.
010    NO WARRANTY IS EITHER EXPRESS OR IMPLIED WITH RESPECT TO THE USE OF THE
011    SOFTWARE OR DOCUMENTATION. Under no circumstances shall University be liable
012    for incidental, special, indirect, direct or consequential damages or loss of
013    profits, interruption of business, or related expenses which may arise from use
014    of Software or Documentation, including but not limited to those resulting from
015    defects in Software and/or Documentation, or loss or inaccuracy of data of any
016    kind.
017    
018    File: Bag.java 
019    
020     */
021    
022    package galois.objects;
023    
024    import java.util.Collection;
025    import java.util.Iterator;
026    
027    /**
028     * A bag of elements.
029     *
030     * @param <T>  type of elements contained in bag
031     */
032    public interface Bag<T> extends Collection<T>, GObject {
033      @Override
034      public boolean add(T o);
035    
036      /**
037       * @param flags Galois runtime actions (e.g., conflict detection) that need to be executed
038       *              upon invocation of this method. See {@link galois.objects.MethodFlag}
039       * @see #add(Object)
040       */
041      public boolean add(T o, byte flags);
042    
043      @Override
044      public boolean addAll(Collection<? extends T> c);
045    
046      /**
047       * @param flags Galois runtime actions (e.g., conflict detection) that need to be executed
048       *              upon invocation of this method. See {@link galois.objects.MethodFlag}
049       * @see #addAll(Collection)
050       */
051      public boolean addAll(Collection<? extends T> c, byte flags);
052    
053      /**
054       * Not supported by this class.
055       */
056      @Override
057      public void clear();
058    
059      /**
060       * Not supported by this class.
061       */
062      public void clear(byte flags);
063    
064      /**
065       * Not supported by this class.
066       */
067      @Override
068      public boolean contains(Object o);
069    
070      /**
071       * Not supported by this class.
072       */
073      public boolean contains(Object o, byte flags);
074    
075      /**
076       * Not supported by this class.
077       */
078      @Override
079      public boolean containsAll(Collection<?> c);
080    
081      /**
082       * Not supported by this class.
083       */
084      public boolean containsAll(Collection<?> c, byte flags);
085    
086      /**
087       * Not supported by this class.
088       */
089      @Override
090      public boolean isEmpty();
091    
092      /**
093       * Not supported by this class.
094       */
095      public boolean isEmpty(byte flags);
096    
097      /**
098       * {@inheritDoc}. Only valid outside parallel execution.
099       */
100      @Override
101      public Iterator<T> iterator();
102    
103      /**
104       * Iterates over all the elements in the bag. Only valid outside
105       * parallel execution.
106       *
107       * @param flags Galois runtime actions (e.g., conflict detection) that need to be executed
108       *              upon invocation of this method. See {@link galois.objects.MethodFlag}
109       * @see #iterator()
110       */
111      public Iterator<T> iterator(byte flags);
112    
113      /**
114       * Not supported by this class.
115       */
116      @Override
117      public boolean remove(Object o);
118    
119      /**
120       * Not supported by this class.
121       */
122      public boolean remove(Object o, byte flags);
123    
124      /**
125       * Not supported by this class.
126       */
127      @Override
128      public boolean removeAll(Collection<?> c);
129    
130      /**
131       * Not supported by this class.
132       */
133      public boolean removeAll(Collection<?> c, byte flags);
134    
135      /**
136       * Not supported by this class.
137       */
138      @Override
139      public boolean retainAll(Collection<?> c);
140    
141      /**
142       * Not supported by this class.
143       */
144      public boolean retainAll(Collection<?> c, byte flags);
145    
146      /**
147       * {@inheritDoc}. Only valid outside parallel execution.
148       */
149      @Override
150      public int size();
151    
152      /**
153       * Number of elements in the bag. Only valid outside parallel execution.
154       *
155       * @param flags Galois runtime actions (e.g., conflict detection) that need to be executed
156       *              upon invocation of this method. See {@link galois.objects.MethodFlag}
157       * @return size of the bag
158       */
159      public int size(byte flags);
160    
161      /**
162       * Not supported by this class.
163       */
164      @Override
165      public Object[] toArray();
166    
167      /**
168       * Not supported by this class.
169       */
170      public Object[] toArray(byte flags);
171    
172      /**
173       * Not supported by this class.
174       */
175      @Override
176      public <U> U[] toArray(U[] a);
177    
178      /**
179       * Not supported by this class.
180       */
181      public <U> U[] toArray(U[] a, byte flags);
182    }