Example #1
0
 @Override
 public boolean set_impl(int i, double d) {
   if (_ds == null) {
     assert sparseLen() == 0 || _ls != null;
     switch_to_doubles();
   }
   if (sparseLen() != _len) { // sparse?
     int idx = Arrays.binarySearch(_id, 0, sparseLen(), i);
     if (idx >= 0) i = idx;
     else cancel_sparse(); // for now don't bother setting the sparse value
   }
   assert i < sparseLen();
   _ds[i] = d;
   _naCnt = -1;
   return true;
 }
Example #2
0
 // Fast-path append double data
 public void addNum(double d) {
   if (isUUID() || isString()) {
     addNA();
     return;
   }
   if (_id == null || d != 0) {
     if (_ls != null) switch_to_doubles();
     if (_ds == null || sparseLen() >= _ds.length) {
       append2slowd();
       // call addNum again since append2slow might have flipped to sparse
       addNum(d);
       assert sparseLen() <= _len;
       return;
     }
     if (_id != null) _id[sparseLen()] = _len;
     _ds[sparseLen()] = d;
     set_sparseLen(sparseLen() + 1);
   }
   set_len(_len + 1);
   assert sparseLen() <= _len;
 }