@Override public T put(DBIDRef id, T value) { if (value == null) { return data.remove(DBIDUtil.deref(id)); } return data.put(DBIDUtil.deref(id), value); }
/** * Actual setter. * * @param id Database ID * @param index column index * @param value new value * @param <T> type * @return previous value */ @SuppressWarnings("unchecked") protected <T> T set(DBIDRef id, int index, T value) { Object[] d = data.get(DBIDUtil.deref(id)); if (d == null) { d = new Object[rlen]; data.put(DBIDUtil.deref(id), d); } T ret = (T) d[index]; d[index] = value; return ret; }
/** * Actual getter. * * @param id Database ID * @param index column index * @param <T> type * @return current value */ @SuppressWarnings("unchecked") protected <T> T get(DBIDRef id, int index) { Object[] d = data.get(DBIDUtil.deref(id)); if (d == null) { return null; } return (T) d[index]; }
@Override public void initialize() { super.initialize(); List<MkAppEntry> objs = new ArrayList<>(relation.size()); for (DBIDIter iter = relation.iterDBIDs(); iter.valid(); iter.advance()) { DBID id = DBIDUtil.deref(iter); final O object = relation.get(id); objs.add(createNewLeafEntry(id, object, Double.NaN)); } insertAll(objs); }
/** * Inserts the specified objects into this index. If a bulk load mode is implemented, the objects * are inserted in one bulk. * * @param ids the objects to be inserted */ @Override public void insertAll(DBIDs ids) { if (ids.isEmpty() || (ids.size() == 1)) { return; } // Make an example leaf if (canBulkLoad()) { List<SpatialEntry> leafs = new ArrayList<>(ids.size()); for (DBIDIter iter = ids.iter(); iter.valid(); iter.advance()) { leafs.add(createNewLeafEntry(iter)); } bulkLoad(leafs); } else { for (DBIDIter iter = ids.iter(); iter.valid(); iter.advance()) { insert(DBIDUtil.deref(iter)); } } doExtraIntegrityChecks(); }
@Override public T get(DBIDRef id) { return data.get(DBIDUtil.deref(id)); }
/** * Create a new leaf entry. * * @param id Object id * @return Spatial leaf entry */ protected SpatialPointLeafEntry createNewLeafEntry(DBIDRef id) { return new SpatialPointLeafEntry(DBIDUtil.deref(id), relation.get(id)); }