MCPcopy Create free account
hub / github.com/EdwardRaff/JSAT / add

Method add

JSAT/src/jsat/utils/IntSortedSet.java:66–87  ·  view source on GitHub ↗
(Integer e)

Source from the content-addressed store, hash-verified

64 }
65
66 @Override
67 public boolean add(Integer e)
68 {
69 if(e == null)
70 return false;
71 int insertionPoint = Arrays.binarySearch(store, 0, size, e);
72 if(insertionPoint >= 0 )
73 return false;//Already in the set
74 //Fix up to where we would like to place it
75 insertionPoint = (-(insertionPoint) - 1);
76
77 //Increase store size if needed
78 if(size >= store.length)
79 store = Arrays.copyOf(store, Math.max(1, store.length)*2);
80
81 for(int i = size; i > insertionPoint; i--)
82 store[i] = store[i-1];
83 store[insertionPoint] = e;
84 size++;
85
86 return true;
87 }
88
89 public boolean contains(int o)
90 {

Callers 6

testAddMethod · 0.95
testIteratorMethod · 0.95
testSizeMethod · 0.95
testSubSetMethod · 0.95
IntSortedSetMethod · 0.95
addMethod · 0.45

Calls 2

copyOfMethod · 0.80
maxMethod · 0.45

Tested by 4

testAddMethod · 0.76
testIteratorMethod · 0.76
testSizeMethod · 0.76
testSubSetMethod · 0.76