@Override public void clear() { Byte2ObjectArrayMap.this.clear(); } };
@Override public boolean contains(final Object v) { return containsValue(v); } @Override
@Override public boolean containsKey(final byte k) { return findKey(k) != -1; } @Override
/** * Given a nodeInfo containing the social proofs and weight information regarding a rightNode, * convert and store these data in a SocialProofResult object, to comply with the class interface. * * @param nodeInfo Contains all the social proofs on a particular right node, along with the * accumulated node weight */ private SocialProofResult makeSocialProofResult(NodeInfo nodeInfo) { Byte2ObjectArrayMap<LongSet> socialProofsMap = new Byte2ObjectArrayMap<>(); for (int socialProofType = 0; socialProofType < NUM_OF_SOCIAL_PROOF_TYPES; socialProofType++) { SmallArrayBasedLongToDoubleMap socialProofsByType = nodeInfo.getSocialProofs()[socialProofType]; if (socialProofsByType == null || socialProofsByType.size() == 0) { continue; } LongSet rightNodeIds = new LongArraySet( Arrays.copyOfRange(socialProofsByType.keys(), 0, socialProofsByType.size())); socialProofsMap.put((byte)socialProofType, rightNodeIds); } return new SocialProofResult( nodeInfo.getNodeId(), socialProofsMap, nodeInfo.getWeight(), recommendationType ); }
/** * Creates a new empty array map copying the entries of a given map. * * @param m * a map. */ public Byte2ObjectArrayMap(final Map<? extends Byte, ? extends V> m) { this(m.size()); putAll(m); } /**
nodeMetadataToSocialProofMap.put(metadataId, new Byte2ObjectArrayMap<>());
/** * Creates a new empty array map copying the entries of a given map. * * @param m * a map. */ public Byte2ObjectArrayMap(final Byte2ObjectMap<V> m) { this(m.size()); putAll(m); } /**
@Override @SuppressWarnings("unchecked") public V put(byte k, V v) { final int oldKey = findKey(k); if (oldKey != -1) { final V oldValue = (V) value[oldKey]; value[oldKey] = v; return oldValue; } if (size == key.length) { final byte[] newKey = new byte[size == 0 ? 2 : size * 2]; final Object[] newValue = new Object[size == 0 ? 2 : size * 2]; for (int i = size; i-- != 0;) { newKey[i] = key[i]; newValue[i] = value[i]; } key = newKey; value = newValue; } key[size] = k; value[size] = v; size++; return defRetValue; } @Override
@Override public void clear() { Byte2ObjectArrayMap.this.clear(); } };
@Override @SuppressWarnings("unchecked") public V remove(final byte k) { final int oldPos = findKey(k); if (oldPos == -1) return defRetValue; final V oldValue = (V) value[oldPos]; final int tail = size - oldPos - 1; System.arraycopy(key, oldPos + 1, key, oldPos, tail); System.arraycopy(value, oldPos + 1, value, oldPos, tail); size--; value[size] = null; return oldValue; } @Override