Skip to content

Commit f5bb992

Browse files
committed
binary and set ideas
1 parent b5227f4 commit f5bb992

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

src/benblack86/binary/BasicBinary.java renamed to src/benblack86/binary/BinaryBasics.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package benblack86.binary;
22

3-
public class BasicBinary {
3+
public class BinaryBasics {
44
public static void main(String args[]) {
55

66
System.out.printf("Capacity of primitives:\n");
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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+
}

0 commit comments

Comments
 (0)