code
stringlengths
23
201k
docstring
stringlengths
17
96.2k
func_name
stringlengths
0
235
language
stringclasses
1 value
repo
stringlengths
8
72
path
stringlengths
11
317
url
stringlengths
57
377
license
stringclasses
7 values
public int getDecoratedMeasurementHorizontal(View view) { final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) view.getLayoutParams(); return getDecoratedMeasuredWidth(view) + params.leftMargin + params.rightMargin; }
@param trasitionListener if null,remove all @return
getDecoratedMeasurementHorizontal
java
CCY0122/FocusLayoutManager
focuslayoutmanager/src/main/java/ccy/focuslayoutmanager/FocusLayoutManager.java
https://github.com/CCY0122/FocusLayoutManager/blob/master/focuslayoutmanager/src/main/java/ccy/focuslayoutmanager/FocusLayoutManager.java
Apache-2.0
public int getDecoratedMeasurementVertical(View view) { final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) view.getLayoutParams(); return getDecoratedMeasuredHeight(view) + params.topMargin + params.bottomMargin; }
@param trasitionListener if null,remove all @return
getDecoratedMeasurementVertical
java
CCY0122/FocusLayoutManager
focuslayoutmanager/src/main/java/ccy/focuslayoutmanager/FocusLayoutManager.java
https://github.com/CCY0122/FocusLayoutManager/blob/master/focuslayoutmanager/src/main/java/ccy/focuslayoutmanager/FocusLayoutManager.java
Apache-2.0
public int getVerticalSpace() { return getHeight() - getPaddingTop() - getPaddingBottom(); }
@param trasitionListener if null,remove all @return
getVerticalSpace
java
CCY0122/FocusLayoutManager
focuslayoutmanager/src/main/java/ccy/focuslayoutmanager/FocusLayoutManager.java
https://github.com/CCY0122/FocusLayoutManager/blob/master/focuslayoutmanager/src/main/java/ccy/focuslayoutmanager/FocusLayoutManager.java
Apache-2.0
public int getHorizontalSpace() { return getWidth() - getPaddingLeft() - getPaddingRight(); }
@param trasitionListener if null,remove all @return
getHorizontalSpace
java
CCY0122/FocusLayoutManager
focuslayoutmanager/src/main/java/ccy/focuslayoutmanager/FocusLayoutManager.java
https://github.com/CCY0122/FocusLayoutManager/blob/master/focuslayoutmanager/src/main/java/ccy/focuslayoutmanager/FocusLayoutManager.java
Apache-2.0
public void resetData() { mFirstVisiPos = 0; mLastVisiPos = 0; onceCompleteScrollLength = -1; mHorizontalOffset = 0; mVerticalOffset = 0; focusdPosition = -1; cancelAnimator(); }
@param trasitionListener if null,remove all @return
resetData
java
CCY0122/FocusLayoutManager
focuslayoutmanager/src/main/java/ccy/focuslayoutmanager/FocusLayoutManager.java
https://github.com/CCY0122/FocusLayoutManager/blob/master/focuslayoutmanager/src/main/java/ccy/focuslayoutmanager/FocusLayoutManager.java
Apache-2.0
public void cancelAnimator() { if (selectAnimator != null && (selectAnimator.isStarted() || selectAnimator.isRunning())) { selectAnimator.cancel(); } }
@param trasitionListener if null,remove all @return
cancelAnimator
java
CCY0122/FocusLayoutManager
focuslayoutmanager/src/main/java/ccy/focuslayoutmanager/FocusLayoutManager.java
https://github.com/CCY0122/FocusLayoutManager/blob/master/focuslayoutmanager/src/main/java/ccy/focuslayoutmanager/FocusLayoutManager.java
Apache-2.0
@Test public void addition_isCorrect() { assertEquals(4, 2 + 2); }
Example local unit test, which will execute on the development machine (host). @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
addition_isCorrect
java
CCY0122/FocusLayoutManager
focuslayoutmanager/src/test/java/ccy/focuslayoutmanager/ExampleUnitTest.java
https://github.com/CCY0122/FocusLayoutManager/blob/master/focuslayoutmanager/src/test/java/ccy/focuslayoutmanager/ExampleUnitTest.java
Apache-2.0
@Test public void addition_isCorrect() throws Exception { assertEquals(4, 2 + 2); }
To work on unit tests, switch the Test Artifact in the Build Variants view.
addition_isCorrect
java
qyxxjd/MultipleStatusView
app/src/test/java/com/classic/common/ExampleUnitTest.java
https://github.com/qyxxjd/MultipleStatusView/blob/master/app/src/test/java/com/classic/common/ExampleUnitTest.java
MIT
@Override public void define(Context context) { NewRepository repository = context .createRepository(REPOSITORY_KEY, "java") .setName("VIPAnalyzer "); List<Class> checks = SonarRulesList.getChecks(); new RulesDefinitionAnnotationLoader().load(repository, Iterables.toArray(checks, Class.class)); for (Class ruleClass : checks) { newRule(ruleClass, repository); } repository.done(); }
Declare rule metadata in server repository of rules. That allows to list the rules in the page "Rules".
define
java
DarLiner/vjtools
standard/sonar-vj/src/main/java/com/vip/vjkit/sonarvj/SonarDefinition.java
https://github.com/DarLiner/vjtools/blob/master/standard/sonar-vj/src/main/java/com/vip/vjkit/sonarvj/SonarDefinition.java
Apache-2.0
@VisibleForTesting protected void newRule(Class<?> ruleClass, NewRepository repository) { org.sonar.check.Rule ruleAnnotation = AnnotationUtils.getAnnotation(ruleClass, org.sonar.check.Rule.class); if (ruleAnnotation == null) { throw new IllegalArgumentException("No Rule annotation was found on " + ruleClass); } String ruleKey = ruleAnnotation.key(); if (StringUtils.isEmpty(ruleKey)) { throw new IllegalArgumentException("No key is defined in Rule annotation of " + ruleClass); } NewRule rule = repository.rule(ruleKey); if (rule == null) { throw new IllegalStateException("No rule was created for " + ruleClass + " in " + repository.key()); } ruleMetadata(ruleClass, rule); rule.setTemplate(AnnotationUtils.getAnnotation(ruleClass, RuleTemplate.class) != null); if (ruleAnnotation.cardinality() == Cardinality.MULTIPLE) { throw new IllegalArgumentException("Cardinality is not supported, use the RuleTemplate annotation instead for " + ruleClass); } }
Declare rule metadata in server repository of rules. That allows to list the rules in the page "Rules".
newRule
java
DarLiner/vjtools
standard/sonar-vj/src/main/java/com/vip/vjkit/sonarvj/SonarDefinition.java
https://github.com/DarLiner/vjtools/blob/master/standard/sonar-vj/src/main/java/com/vip/vjkit/sonarvj/SonarDefinition.java
Apache-2.0
private String ruleMetadata(Class<?> ruleClass, NewRule rule) { String metadataKey = rule.key(); org.sonar.java.RspecKey rspecKeyAnnotation = AnnotationUtils.getAnnotation(ruleClass, org.sonar.java.RspecKey.class); if (rspecKeyAnnotation != null) { metadataKey = rspecKeyAnnotation.value(); rule.setInternalKey(metadataKey); } addHtmlDescription(rule, metadataKey); addMetadata(rule, metadataKey); return metadataKey; }
Declare rule metadata in server repository of rules. That allows to list the rules in the page "Rules".
ruleMetadata
java
DarLiner/vjtools
standard/sonar-vj/src/main/java/com/vip/vjkit/sonarvj/SonarDefinition.java
https://github.com/DarLiner/vjtools/blob/master/standard/sonar-vj/src/main/java/com/vip/vjkit/sonarvj/SonarDefinition.java
Apache-2.0
private void addMetadata(NewRule rule, String metadataKey) { URL resource = SonarDefinition.class.getResource(RESOURCE_BASE_PATH + "/" + metadataKey + "_java.json"); if (resource != null) { RuleMetatada metatada = gson.fromJson(readResource(resource), RuleMetatada.class); rule.setSeverity(metatada.defaultSeverity.toUpperCase(Locale.US)); rule.setName(metatada.title); rule.addTags(metatada.tags); rule.setType(RuleType.valueOf(metatada.type)); rule.setStatus(RuleStatus.valueOf(metatada.status.toUpperCase(Locale.US))); if (metatada.remediation != null) { rule.setDebtRemediationFunction(metatada.remediation.remediationFunction(rule.debtRemediationFunctions())); rule.setGapDescription(metatada.remediation.linearDesc); } } }
Declare rule metadata in server repository of rules. That allows to list the rules in the page "Rules".
addMetadata
java
DarLiner/vjtools
standard/sonar-vj/src/main/java/com/vip/vjkit/sonarvj/SonarDefinition.java
https://github.com/DarLiner/vjtools/blob/master/standard/sonar-vj/src/main/java/com/vip/vjkit/sonarvj/SonarDefinition.java
Apache-2.0
private static void addHtmlDescription(NewRule rule, String metadataKey) { URL resource = SonarDefinition.class.getResource(RESOURCE_BASE_PATH + "/" + metadataKey + "_java.html"); if (resource != null) { rule.setHtmlDescription(readResource(resource)); } }
Declare rule metadata in server repository of rules. That allows to list the rules in the page "Rules".
addHtmlDescription
java
DarLiner/vjtools
standard/sonar-vj/src/main/java/com/vip/vjkit/sonarvj/SonarDefinition.java
https://github.com/DarLiner/vjtools/blob/master/standard/sonar-vj/src/main/java/com/vip/vjkit/sonarvj/SonarDefinition.java
Apache-2.0
private static String readResource(URL resource) { try { return Resources.toString(resource, StandardCharsets.UTF_8); } catch (IOException e) { throw new IllegalStateException("Failed to read: " + resource, e); } }
Declare rule metadata in server repository of rules. That allows to list the rules in the page "Rules".
readResource
java
DarLiner/vjtools
standard/sonar-vj/src/main/java/com/vip/vjkit/sonarvj/SonarDefinition.java
https://github.com/DarLiner/vjtools/blob/master/standard/sonar-vj/src/main/java/com/vip/vjkit/sonarvj/SonarDefinition.java
Apache-2.0
public DebtRemediationFunction remediationFunction(DebtRemediationFunctions drf) { if (func.startsWith("Constant")) { return drf.constantPerIssue(constantCost.replace("mn", "min")); } if ("Linear".equals(func)) { return drf.linear(linearFactor.replace("mn", "min")); } return drf.linearWithOffset(linearFactor.replace("mn", "min"), linearOffset.replace("mn", "min")); }
Declare rule metadata in server repository of rules. That allows to list the rules in the page "Rules".
remediationFunction
java
DarLiner/vjtools
standard/sonar-vj/src/main/java/com/vip/vjkit/sonarvj/SonarDefinition.java
https://github.com/DarLiner/vjtools/blob/master/standard/sonar-vj/src/main/java/com/vip/vjkit/sonarvj/SonarDefinition.java
Apache-2.0
public Comparator getComparator() { return comparator; }
Returns comparator assigned to this collection, if such exist.
getComparator
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/SortedArrayList.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/SortedArrayList.java
Apache-2.0
@Override public boolean add(E o) { int idx = 0; if (!isEmpty()) { idx = findInsertionPoint(o); } super.add(idx, o); return true; }
Adds an Object to sorted list. Object is inserted at correct place, found using binary search. If the same item exist, it will be put to the end of the range. <p> This method breaks original list contract since objects are not added at the list end, but in sorted manner.
add
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/SortedArrayList.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/SortedArrayList.java
Apache-2.0
@Override public boolean addAll(Collection<? extends E> c) { Iterator<? extends E> i = c.iterator(); boolean changed = false; while (i.hasNext()) { boolean ret = add(i.next()); if (!changed) { changed = ret; } } return changed; }
Add all of the elements in the given collection to this list.
addAll
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/SortedArrayList.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/SortedArrayList.java
Apache-2.0
public int findInsertionPoint(E o) { return findInsertionPoint(o, 0, size() - 1); }
Finds the index at which object should be inserted.
findInsertionPoint
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/SortedArrayList.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/SortedArrayList.java
Apache-2.0
@Override @Deprecated public void add(int index, E element) { throw new UnsupportedOperationException(); }
@throws UnsupportedOperationException This method not supported.
add
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/SortedArrayList.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/SortedArrayList.java
Apache-2.0
@Override @Deprecated public E set(int index, E element) { throw new UnsupportedOperationException(); }
@throws UnsupportedOperationException This method not supported.
set
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/SortedArrayList.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/SortedArrayList.java
Apache-2.0
@Override @Deprecated public boolean addAll(int index, Collection<? extends E> c) { throw new UnsupportedOperationException(); }
@throws UnsupportedOperationException This method not supported.
addAll
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/SortedArrayList.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/SortedArrayList.java
Apache-2.0
@SuppressWarnings( {"unchecked"}) protected int compare(E k1, E k2) { if (comparator == null) { return ((Comparable) k1).compareTo(k2); } return comparator.compare(k1, k2); }
Compares two keys using the correct comparison method for this collection.
compare
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/SortedArrayList.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/SortedArrayList.java
Apache-2.0
protected int findInsertionPoint(E o, int originalLow, int originalHigh) { int low = originalLow; int high = originalHigh; while (low <= high) { int mid = low + ((high - low) >>> 1); int delta = compare(get(mid), o); if (delta > 0) { high = mid - 1; } else { low = mid + 1; } } return low; }
Conducts a binary search to find the index where Object should be inserted.
findInsertionPoint
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/SortedArrayList.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/SortedArrayList.java
Apache-2.0
@Override public Iterator<PrimitiveEntry<V>> iterator() { return new PrimitiveIterator(); }
The load factor for the map. Used to calculate {@link #maxSize}.
iterator
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
Apache-2.0
private static <T> T toExternal(T value) { assert value != null : "null is not a legitimate internal value. Concurrent Modification?"; return value == NULL_VALUE ? null : value; }
The load factor for the map. Used to calculate {@link #maxSize}.
toExternal
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
Apache-2.0
@SuppressWarnings("unchecked") private static <T> T toInternal(T value) { return value == null ? (T) NULL_VALUE : value; }
The load factor for the map. Used to calculate {@link #maxSize}.
toInternal
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
Apache-2.0
@Override public V get(int key) { int index = indexOf(key); return index == -1 ? null : toExternal(values[index]); }
The load factor for the map. Used to calculate {@link #maxSize}.
get
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
Apache-2.0
@Override public V put(int key, V value) { int startIndex = hashIndex(key); int index = startIndex; for (;;) { if (values[index] == null) { // Found empty slot, use it. keys[index] = key; values[index] = toInternal(value); growSize(); return null; } if (keys[index] == key) { // Found existing entry with this key, just replace the value. V previousValue = values[index]; values[index] = toInternal(value); return toExternal(previousValue); } // Conflict, keep probing ... if ((index = probeNext(index)) == startIndex) { // Can only happen if the map was full at MAX_ARRAY_SIZE and couldn't grow. throw new IllegalStateException("Unable to insert"); } } }
The load factor for the map. Used to calculate {@link #maxSize}.
put
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
Apache-2.0
@Override public void putAll(Map<? extends Integer, ? extends V> sourceMap) { if (sourceMap instanceof IntObjectHashMap) { // Optimization - iterate through the arrays. @SuppressWarnings("unchecked") IntObjectHashMap<V> source = (IntObjectHashMap<V>) sourceMap; for (int i = 0; i < source.values.length; ++i) { V sourceValue = source.values[i]; if (sourceValue != null) { put(source.keys[i], sourceValue); } } return; } // Otherwise, just add each entry. for (Entry<? extends Integer, ? extends V> entry : sourceMap.entrySet()) { put(entry.getKey(), entry.getValue()); } }
The load factor for the map. Used to calculate {@link #maxSize}.
putAll
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
Apache-2.0
@Override public V remove(int key) { int index = indexOf(key); if (index == -1) { return null; } V prev = values[index]; removeAt(index); return toExternal(prev); }
The load factor for the map. Used to calculate {@link #maxSize}.
remove
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
Apache-2.0
@Override public int size() { return size; }
The load factor for the map. Used to calculate {@link #maxSize}.
size
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
Apache-2.0
@Override public boolean isEmpty() { return size == 0; }
The load factor for the map. Used to calculate {@link #maxSize}.
isEmpty
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
Apache-2.0
@Override public void clear() { Arrays.fill(keys, (int) 0); Arrays.fill(values, null); size = 0; }
The load factor for the map. Used to calculate {@link #maxSize}.
clear
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
Apache-2.0
@Override public boolean containsKey(int key) { return indexOf(key) >= 0; }
The load factor for the map. Used to calculate {@link #maxSize}.
containsKey
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
Apache-2.0
@Override public boolean containsValue(Object value) { @SuppressWarnings("unchecked") V v1 = toInternal((V) value); for (V v2 : values) { // The map supports null values; this will be matched as NULL_VALUE.equals(NULL_VALUE). if (v2 != null && v2.equals(v1)) { return true; } } return false; }
The load factor for the map. Used to calculate {@link #maxSize}.
containsValue
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
Apache-2.0
@Override public Iterable<PrimitiveEntry<V>> entries() { return entries; }
The load factor for the map. Used to calculate {@link #maxSize}.
entries
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
Apache-2.0
@Override public Collection<V> values() { return new AbstractCollection<V>() { @Override public Iterator<V> iterator() { return new Iterator<V>() { final PrimitiveIterator iter = new PrimitiveIterator(); @Override public boolean hasNext() { return iter.hasNext(); } @Override public V next() { return iter.next().value(); } @Override public void remove() { throw new UnsupportedOperationException(); } }; } @Override public int size() { return size; } }; }
The load factor for the map. Used to calculate {@link #maxSize}.
values
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
Apache-2.0
@Override public Iterator<V> iterator() { return new Iterator<V>() { final PrimitiveIterator iter = new PrimitiveIterator(); @Override public boolean hasNext() { return iter.hasNext(); } @Override public V next() { return iter.next().value(); } @Override public void remove() { throw new UnsupportedOperationException(); } }; }
The load factor for the map. Used to calculate {@link #maxSize}.
iterator
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
Apache-2.0
@Override public boolean hasNext() { return iter.hasNext(); }
The load factor for the map. Used to calculate {@link #maxSize}.
hasNext
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
Apache-2.0
@Override public V next() { return iter.next().value(); }
The load factor for the map. Used to calculate {@link #maxSize}.
next
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
Apache-2.0
@Override public void remove() { throw new UnsupportedOperationException(); }
The load factor for the map. Used to calculate {@link #maxSize}.
remove
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
Apache-2.0
@Override public int size() { return size; }
The load factor for the map. Used to calculate {@link #maxSize}.
size
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
Apache-2.0
@Override public int hashCode() { // Hashcode is based on all non-zero, valid keys. We have to scan the whole keys // array, which may have different lengths for two maps of same size(), so the // capacity cannot be used as input for hashing but the size can. int hash = size; for (int key : keys) { // 0 can be a valid key or unused slot, but won't impact the hashcode in either case. // This way we can use a cheap loop without conditionals, or hard-to-unroll operations, // or the devastatingly bad memory locality of visiting value objects. // Also, it's important to use a hash function that does not depend on the ordering // of terms, only their values; since the map is an unordered collection and // entries can end up in different positions in different maps that have the same // elements, but with different history of puts/removes, due to conflicts. hash ^= hashCode(key); } return hash; }
The load factor for the map. Used to calculate {@link #maxSize}.
hashCode
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
Apache-2.0
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof IntObjectMap)) { return false; } @SuppressWarnings("rawtypes") IntObjectMap other = (IntObjectMap) obj; if (size != other.size()) { return false; } for (int i = 0; i < values.length; ++i) { V value = values[i]; if (value != null) { int key = keys[i]; Object otherValue = other.get(key); if (value == NULL_VALUE) { if (otherValue != null) { return false; } } else if (!value.equals(otherValue)) { return false; } } } return true; }
The load factor for the map. Used to calculate {@link #maxSize}.
equals
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
Apache-2.0
@Override public boolean containsKey(Object key) { return containsKey(objectToKey(key)); }
The load factor for the map. Used to calculate {@link #maxSize}.
containsKey
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
Apache-2.0
@Override public V get(Object key) { return get(objectToKey(key)); }
The load factor for the map. Used to calculate {@link #maxSize}.
get
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
Apache-2.0
@Override public V put(Integer key, V value) { return put(objectToKey(key), value); }
The load factor for the map. Used to calculate {@link #maxSize}.
put
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
Apache-2.0
@Override public V remove(Object key) { return remove(objectToKey(key)); }
The load factor for the map. Used to calculate {@link #maxSize}.
remove
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
Apache-2.0
@Override public Set<Integer> keySet() { return keySet; }
The load factor for the map. Used to calculate {@link #maxSize}.
keySet
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
Apache-2.0
@Override public Set<Entry<Integer, V>> entrySet() { return entrySet; }
The load factor for the map. Used to calculate {@link #maxSize}.
entrySet
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
Apache-2.0
private int objectToKey(Object key) { return (int) ((Integer) key).intValue(); }
The load factor for the map. Used to calculate {@link #maxSize}.
objectToKey
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
Apache-2.0
private int indexOf(int key) { int startIndex = hashIndex(key); int index = startIndex; for (;;) { if (values[index] == null) { // It's available, so no chance that this value exists anywhere in the map. return -1; } if (key == keys[index]) { return index; } // Conflict, keep probing ... if ((index = probeNext(index)) == startIndex) { return -1; } } }
Locates the index for the given key. This method probes using double hashing. @param key the key for an entry in the map. @return the index where the key was found, or {@code -1} if no entry is found for that key.
indexOf
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
Apache-2.0
private int hashIndex(int key) { // The array lengths are always a power of two, so we can use a bitmask to stay inside the array bounds. return hashCode(key) & mask; }
Returns the hashed index for the given key.
hashIndex
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
Apache-2.0
private static int hashCode(int key) { return (int) key; }
Returns the hash code for the key.
hashCode
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
Apache-2.0
private int probeNext(int index) { // The array lengths are always a power of two, so we can use a bitmask to stay inside the array bounds. return (index + 1) & mask; }
Get the next sequential index after {@code index} and wraps if necessary.
probeNext
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
Apache-2.0
private void growSize() { size++; if (size > maxSize) { if (keys.length == Integer.MAX_VALUE) { throw new IllegalStateException("Max capacity reached at size=" + size); } // Double the capacity. rehash(keys.length << 1); } }
Grows the map size after an insertion. If necessary, performs a rehash of the map.
growSize
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
Apache-2.0
private boolean removeAt(final int index) { --size; // Clearing the key is not strictly necessary (for GC like in a regular collection), // but recommended for security. The memory location is still fresh in the cache anyway. keys[index] = 0; values[index] = null; // In the interval from index to the next available entry, the arrays may have entries // that are displaced from their base position due to prior conflicts. Iterate these // entries and move them back if possible, optimizing future lookups. // Knuth Section 6.4 Algorithm R, also used by the JDK's IdentityHashMap. int nextFree = index; int i = probeNext(index); for (V value = values[i]; value != null; value = values[i = probeNext(i)]) { int key = keys[i]; int bucket = hashIndex(key); if (i < bucket && (bucket <= nextFree || nextFree <= i) || bucket <= nextFree && nextFree <= i) { // Move the displaced entry "back" to the first available position. keys[nextFree] = key; values[nextFree] = value; // Put the first entry after the displaced entry keys[i] = 0; values[i] = null; nextFree = i; } } return nextFree != index; }
Removes entry at the given index position. Also performs opportunistic, incremental rehashing if necessary to not break conflict chains. @param index the index position of the element to remove. @return {@code true} if the next item was moved back. {@code false} otherwise.
removeAt
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
Apache-2.0
private int calcMaxSize(int capacity) { // Clip the upper bound so that there will always be at least one available slot. int upperBound = capacity - 1; return Math.min(upperBound, (int) (capacity * loadFactor)); }
Calculates the maximum size allowed before rehashing.
calcMaxSize
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
Apache-2.0
private void rehash(int newCapacity) { int[] oldKeys = keys; V[] oldVals = values; keys = new int[newCapacity]; @SuppressWarnings({ "unchecked", "SuspiciousArrayCast" }) V[] temp = (V[]) new Object[newCapacity]; values = temp; maxSize = calcMaxSize(newCapacity); mask = newCapacity - 1; // Insert to the new arrays. for (int i = 0; i < oldVals.length; ++i) { V oldVal = oldVals[i]; if (oldVal != null) { // Inlined put(), but much simpler: we don't need to worry about // duplicated keys, growing/rehashing, or failing to insert. int oldKey = oldKeys[i]; int index = hashIndex(oldKey); for (;;) { if (values[index] == null) { keys[index] = oldKey; values[index] = oldVal; break; } // Conflict, keep probing. Can wrap around, but never reaches startIndex again. index = probeNext(index); } } } }
Rehashes the map for the given capacity. @param newCapacity the new capacity for the map.
rehash
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
Apache-2.0
@Override public String toString() { if (isEmpty()) { return "{}"; } StringBuilder sb = new StringBuilder(4 * size); sb.append('{'); boolean first = true; for (int i = 0; i < values.length; ++i) { V value = values[i]; if (value != null) { if (!first) { sb.append(", "); } sb.append(keyToString(keys[i])).append('=').append(value == this ? "(this Map)" : toExternal(value)); first = false; } } return sb.append('}').toString(); }
Rehashes the map for the given capacity. @param newCapacity the new capacity for the map.
toString
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
Apache-2.0
protected String keyToString(int key) { return Integer.toString(key); }
Helper method called by {@link #toString()} in order to convert a single map key into a string. This is protected to allow subclasses to override the appearance of a given key.
keyToString
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
Apache-2.0
@Override public Iterator<Entry<Integer, V>> iterator() { return new MapIterator(); }
Set implementation for iterating over the entries of the map.
iterator
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
Apache-2.0
@Override public int size() { return IntObjectHashMap.this.size(); }
Set implementation for iterating over the entries of the map.
size
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
Apache-2.0
@Override public int size() { return IntObjectHashMap.this.size(); }
Set implementation for iterating over the keys.
size
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
Apache-2.0
@Override public boolean contains(Object o) { return IntObjectHashMap.this.containsKey(o); }
Set implementation for iterating over the keys.
contains
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
Apache-2.0
@Override public boolean remove(Object o) { return IntObjectHashMap.this.remove(o) != null; }
Set implementation for iterating over the keys.
remove
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
Apache-2.0
@Override public boolean retainAll(Collection<?> retainedKeys) { boolean changed = false; for (Iterator<PrimitiveEntry<V>> iter = entries().iterator(); iter.hasNext();) { PrimitiveEntry<V> entry = iter.next(); if (!retainedKeys.contains(entry.key())) { changed = true; iter.remove(); } } return changed; }
Set implementation for iterating over the keys.
retainAll
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
Apache-2.0
@Override public void clear() { IntObjectHashMap.this.clear(); }
Set implementation for iterating over the keys.
clear
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
Apache-2.0
@Override public Iterator<Integer> iterator() { return new Iterator<Integer>() { private final Iterator<Entry<Integer, V>> iter = entrySet.iterator(); @Override public boolean hasNext() { return iter.hasNext(); } @Override public Integer next() { return iter.next().getKey(); } @Override public void remove() { iter.remove(); } }; }
Set implementation for iterating over the keys.
iterator
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
Apache-2.0
@Override public boolean hasNext() { return iter.hasNext(); }
Set implementation for iterating over the keys.
hasNext
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
Apache-2.0
@Override public Integer next() { return iter.next().getKey(); }
Set implementation for iterating over the keys.
next
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
Apache-2.0
@Override public void remove() { iter.remove(); }
Set implementation for iterating over the keys.
remove
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
Apache-2.0
@Override public boolean hasNext() { return iter.hasNext(); }
Iterator used by the {@link Map} interface.
hasNext
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
Apache-2.0
@Override public Entry<Integer, V> next() { if (!hasNext()) { throw new NoSuchElementException(); } iter.next(); return new MapEntry(iter.entryIndex); }
Iterator used by the {@link Map} interface.
next
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/IntObjectHashMap.java
Apache-2.0
@Override public Iterator<PrimitiveEntry<V>> iterator() { return new PrimitiveIterator(); }
The load factor for the map. Used to calculate {@link #maxSize}.
iterator
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java
Apache-2.0
private static <T> T toExternal(T value) { assert value != null : "null is not a legitimate internal value. Concurrent Modification?"; return value == NULL_VALUE ? null : value; }
The load factor for the map. Used to calculate {@link #maxSize}.
toExternal
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java
Apache-2.0
@SuppressWarnings("unchecked") private static <T> T toInternal(T value) { return value == null ? (T) NULL_VALUE : value; }
The load factor for the map. Used to calculate {@link #maxSize}.
toInternal
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java
Apache-2.0
@Override public V get(long key) { int index = indexOf(key); return index == -1 ? null : toExternal(values[index]); }
The load factor for the map. Used to calculate {@link #maxSize}.
get
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java
Apache-2.0
@Override public V put(long key, V value) { int startIndex = hashIndex(key); int index = startIndex; for (;;) { if (values[index] == null) { // Found empty slot, use it. keys[index] = key; values[index] = toInternal(value); growSize(); return null; } if (keys[index] == key) { // Found existing entry with this key, just replace the value. V previousValue = values[index]; values[index] = toInternal(value); return toExternal(previousValue); } // Conflict, keep probing ... if ((index = probeNext(index)) == startIndex) { // Can only happen if the map was full at MAX_ARRAY_SIZE and couldn't grow. throw new IllegalStateException("Unable to insert"); } } }
The load factor for the map. Used to calculate {@link #maxSize}.
put
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java
Apache-2.0
@Override public void putAll(Map<? extends Long, ? extends V> sourceMap) { if (sourceMap instanceof LongObjectHashMap) { // Optimization - iterate through the arrays. @SuppressWarnings("unchecked") LongObjectHashMap<V> source = (LongObjectHashMap<V>) sourceMap; for (int i = 0; i < source.values.length; ++i) { V sourceValue = source.values[i]; if (sourceValue != null) { put(source.keys[i], sourceValue); } } return; } // Otherwise, just add each entry. for (Entry<? extends Long, ? extends V> entry : sourceMap.entrySet()) { put(entry.getKey(), entry.getValue()); } }
The load factor for the map. Used to calculate {@link #maxSize}.
putAll
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java
Apache-2.0
@Override public V remove(long key) { int index = indexOf(key); if (index == -1) { return null; } V prev = values[index]; removeAt(index); return toExternal(prev); }
The load factor for the map. Used to calculate {@link #maxSize}.
remove
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java
Apache-2.0
@Override public int size() { return size; }
The load factor for the map. Used to calculate {@link #maxSize}.
size
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java
Apache-2.0
@Override public boolean isEmpty() { return size == 0; }
The load factor for the map. Used to calculate {@link #maxSize}.
isEmpty
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java
Apache-2.0
@Override public void clear() { Arrays.fill(keys, (long) 0); Arrays.fill(values, null); size = 0; }
The load factor for the map. Used to calculate {@link #maxSize}.
clear
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java
Apache-2.0
@Override public boolean containsKey(long key) { return indexOf(key) >= 0; }
The load factor for the map. Used to calculate {@link #maxSize}.
containsKey
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java
Apache-2.0
@Override public boolean containsValue(Object value) { @SuppressWarnings("unchecked") V v1 = toInternal((V) value); for (V v2 : values) { // The map supports null values; this will be matched as NULL_VALUE.equals(NULL_VALUE). if (v2 != null && v2.equals(v1)) { return true; } } return false; }
The load factor for the map. Used to calculate {@link #maxSize}.
containsValue
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java
Apache-2.0
@Override public Iterable<PrimitiveEntry<V>> entries() { return entries; }
The load factor for the map. Used to calculate {@link #maxSize}.
entries
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java
Apache-2.0
@Override public Collection<V> values() { return new AbstractCollection<V>() { @Override public Iterator<V> iterator() { return new Iterator<V>() { final PrimitiveIterator iter = new PrimitiveIterator(); @Override public boolean hasNext() { return iter.hasNext(); } @Override public V next() { return iter.next().value(); } @Override public void remove() { throw new UnsupportedOperationException(); } }; } @Override public int size() { return size; } }; }
The load factor for the map. Used to calculate {@link #maxSize}.
values
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java
Apache-2.0
@Override public Iterator<V> iterator() { return new Iterator<V>() { final PrimitiveIterator iter = new PrimitiveIterator(); @Override public boolean hasNext() { return iter.hasNext(); } @Override public V next() { return iter.next().value(); } @Override public void remove() { throw new UnsupportedOperationException(); } }; }
The load factor for the map. Used to calculate {@link #maxSize}.
iterator
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java
Apache-2.0
@Override public boolean hasNext() { return iter.hasNext(); }
The load factor for the map. Used to calculate {@link #maxSize}.
hasNext
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java
Apache-2.0
@Override public V next() { return iter.next().value(); }
The load factor for the map. Used to calculate {@link #maxSize}.
next
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java
Apache-2.0
@Override public void remove() { throw new UnsupportedOperationException(); }
The load factor for the map. Used to calculate {@link #maxSize}.
remove
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java
Apache-2.0
@Override public int size() { return size; }
The load factor for the map. Used to calculate {@link #maxSize}.
size
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java
Apache-2.0
@Override public int hashCode() { // Hashcode is based on all non-zero, valid keys. We have to scan the whole keys // array, which may have different lengths for two maps of same size(), so the // capacity cannot be used as input for hashing but the size can. int hash = size; for (long key : keys) { // 0 can be a valid key or unused slot, but won't impact the hashcode in either case. // This way we can use a cheap loop without conditionals, or hard-to-unroll operations, // or the devastatingly bad memory locality of visiting value objects. // Also, it's important to use a hash function that does not depend on the ordering // of terms, only their values; since the map is an unordered collection and // entries can end up in different positions in different maps that have the same // elements, but with different history of puts/removes, due to conflicts. hash ^= hashCode(key); } return hash; }
The load factor for the map. Used to calculate {@link #maxSize}.
hashCode
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java
Apache-2.0
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof LongObjectMap)) { return false; } @SuppressWarnings("rawtypes") LongObjectMap other = (LongObjectMap) obj; if (size != other.size()) { return false; } for (int i = 0; i < values.length; ++i) { V value = values[i]; if (value != null) { long key = keys[i]; Object otherValue = other.get(key); if (value == NULL_VALUE) { if (otherValue != null) { return false; } } else if (!value.equals(otherValue)) { return false; } } } return true; }
The load factor for the map. Used to calculate {@link #maxSize}.
equals
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java
Apache-2.0
@Override public boolean containsKey(Object key) { return containsKey(objectToKey(key)); }
The load factor for the map. Used to calculate {@link #maxSize}.
containsKey
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java
Apache-2.0
@Override public V get(Object key) { return get(objectToKey(key)); }
The load factor for the map. Used to calculate {@link #maxSize}.
get
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java
Apache-2.0
@Override public V put(Long key, V value) { return put(objectToKey(key), value); }
The load factor for the map. Used to calculate {@link #maxSize}.
put
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java
Apache-2.0
@Override public V remove(Object key) { return remove(objectToKey(key)); }
The load factor for the map. Used to calculate {@link #maxSize}.
remove
java
DarLiner/vjtools
vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java
https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java
Apache-2.0