• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* GENERATED SOURCE. DO NOT MODIFY. */
2 // © 2018 and later: Unicode, Inc. and others.
3 // License & terms of use: http://www.unicode.org/copyright.html#License
4 package ohos.global.icu.impl;
5 
6 import java.util.Collection;
7 import java.util.Iterator;
8 import java.util.Set;
9 
10 /**
11  * A wrapper around java.util.Collection that implements java.util.Set. This class keeps a pointer to the
12  * Collection and does not persist any data on its own.
13  *
14  * Useful when you need a Set but creating a HashSet is too expensive.
15  *
16  * IMPORTANT: The elements of the Collection *must* be unique! This class does not check.
17  * @hide exposed on OHOS
18  */
19 public class CollectionSet<E> implements Set<E> {
20 
21     private final Collection<E> data;
22 
CollectionSet(Collection<E> data)23     public CollectionSet(Collection<E> data) {
24         this.data = data;
25     }
26 
27     @Override
size()28     public int size() {
29         return data.size();
30     }
31 
32     @Override
isEmpty()33     public boolean isEmpty() {
34         return data.isEmpty();
35     }
36 
37     @Override
contains(Object o)38     public boolean contains(Object o) {
39         return data.contains(o);
40     }
41 
42     @Override
iterator()43     public Iterator<E> iterator() {
44         return data.iterator();
45     }
46 
47     @Override
toArray()48     public Object[] toArray() {
49         return data.toArray();
50     }
51 
52     @Override
toArray(T[] a)53     public <T> T[] toArray(T[] a) {
54         return data.toArray(a);
55     }
56 
57     @Override
add(E e)58     public boolean add(E e) {
59         return data.add(e);
60     }
61 
62     @Override
remove(Object o)63     public boolean remove(Object o) {
64         return data.remove(o);
65     }
66 
67     @Override
containsAll(Collection<?> c)68     public boolean containsAll(Collection<?> c) {
69         return data.containsAll(c);
70     }
71 
72     @Override
addAll(Collection<? extends E> c)73     public boolean addAll(Collection<? extends E> c) {
74         return data.addAll(c);
75     }
76 
77     @Override
retainAll(Collection<?> c)78     public boolean retainAll(Collection<?> c) {
79         return data.retainAll(c);
80     }
81 
82     @Override
removeAll(Collection<?> c)83     public boolean removeAll(Collection<?> c) {
84         return data.removeAll(c);
85     }
86 
87     @Override
clear()88     public void clear() {
89         data.clear();
90     }
91 }
92