File tree Expand file tree Collapse file tree 2 files changed +40
-1
lines changed Expand file tree Collapse file tree 2 files changed +40
-1
lines changed Original file line number Diff line number Diff line change 1
1
package benblack86 .binary ;
2
2
3
- public class BasicBinary {
3
+ public class BinaryBasics {
4
4
public static void main (String args []) {
5
5
6
6
System .out .printf ("Capacity of primitives:\n " );
Original file line number Diff line number Diff line change
1
+ package benblack86 .collection ;
2
+
3
+ public class SetBasics {
4
+
5
+ public static void main (String [] args ) {
6
+ // java.util.HashSet
7
+ // - implemented using a hash table (should be bigger than N)
8
+ // - not thread safe, iterators are fail-fast
9
+ // add : O(1)
10
+ // remove : O(1)
11
+ // contains : O(1)
12
+ // iteration : O(size of hash table)
13
+
14
+ // java.util.LinkedHashSet
15
+ // - inherits from HashSet but iteration is ordered by the how they were added
16
+ // - maintains a link list on the elements in addition to the hash table
17
+ // - not thread safe, iterators are fail-fast
18
+ // add : O(1)
19
+ // remove : O(1)
20
+ // contains : O(1)
21
+ // iteration : O(N)
22
+
23
+ // java.util.concurrent.CopyOnWriteArraySet
24
+ // - implemented using an array, which is copied on each write
25
+ // - thread safe
26
+ // add : O(N)
27
+ // remove : not supported
28
+ // contains : O(N)
29
+
30
+ // java.util.EnumSet
31
+ // - implemented as a bit vector, can only hold enums, very fast
32
+ // - sets are created using factory methods
33
+ // add : O(1)
34
+ // remove : O(1)
35
+ // contains : O(1)
36
+ // iteration : O(N)
37
+ }
38
+
39
+ }
You can’t perform that action at this time.
0 commit comments