/** * Iterate over all value in the map which are not at {@link #initialValue()}. * * @param consumer called for each key/value pair in the map. */ public void forEach(final LongLongConsumer consumer) { final long[] entries = this.entries; final long initialValue = this.initialValue; @DoNotSub final int length = entries.length; for (@DoNotSub int i = 0; i < length; i += 2) { if (entries[i + 1] != initialValue) // lgtm [java/index-out-of-bounds] { consumer.accept(entries[i], entries[i + 1]); // lgtm [java/index-out-of-bounds] } } }
/** * Primitive specialised forEach implementation. * <p> * NB: Renamed from forEach to avoid overloading on parameter types of lambda * expression, which doesn't longerplay well with type inference in lambda expressions. * * @param consumer a callback called for each key/value pair in the map. */ public void longForEach(final LongLongConsumer consumer) { final long[] entries = this.entries; final long missingValue = this.missingValue; @DoNotSub final int length = entries.length; for (@DoNotSub int keyIndex = 0; keyIndex < length; keyIndex += 2) { if (entries[keyIndex + 1] != missingValue) // lgtm [java/index-out-of-bounds] { consumer.accept(entries[keyIndex], entries[keyIndex + 1]); // lgtm [java/index-out-of-bounds] } } }
/** * Primitive specialised forEach implementation. * <p> * NB: Renamed from forEach to avoid overloading on parameter types of lambda * expression, which doesn't longerplay well with type inference in lambda expressions. * * @param consumer a callback called for each key/value pair in the map. */ public void longForEach(final LongLongConsumer consumer) { final long[] entries = this.entries; final long missingValue = this.missingValue; @DoNotSub final int length = entries.length; for (@DoNotSub int i = 0; i < length; i += 2) { final long key = entries[i]; if (key != missingValue) { consumer.accept(entries[i], entries[i + 1]); } } }