Example #1
0
 // Append a string, store in _ss & _is
 public void addStr(Object str) {
   if (_id == null || str != null) {
     if (_is == null || sparseLen() >= _is.length) {
       append2slowstr();
       addStr(str);
       assert sparseLen() <= _len;
       return;
     }
     if (str != null) {
       if (_id != null) _id[sparseLen()] = _len;
       _is[sparseLen()] = _sslen;
       set_sparseLen(sparseLen() + 1);
       if (str instanceof BufferedString) append_ss((BufferedString) str);
       else // this spares some callers from an unneeded conversion to BufferedString first
       append_ss((String) str);
     } else if (_id == null) {
       _is[sparseLen()] = CStrChunk.NA;
       set_sparseLen(sparseLen() + 1);
     }
   }
   set_len(_len + 1);
   assert sparseLen() <= _len;
 }
Example #2
0
 @Override
 boolean set_impl(int i, String str) {
   if (_is == null && _len > 0) {
     assert sparseLen() == 0;
     alloc_str_indices(_len);
     Arrays.fill(_is, -1);
   }
   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
   }
   _is[i] = _sslen;
   append_ss(str);
   return true;
 }
Example #3
0
 // Append a String, stored in _ss & _is
 public void addStr(ValueString str) {
   if (_id == null || str != null) {
     if (_is == null || sparseLen() >= _is.length) {
       append2slowstr();
       addStr(str);
       assert sparseLen() <= _len;
       return;
     }
     if (str != null) {
       if (_id != null) _id[sparseLen()] = _len;
       _is[sparseLen()] = _sslen;
       set_sparseLen(sparseLen() + 1);
       append_ss(str);
     } else if (_id == null) {
       _is[sparseLen()] = CStrChunk.NA;
       set_sparseLen(sparseLen() + 1);
     }
   }
   set_len(_len + 1);
   assert sparseLen() <= _len;
 }