/** * Returns a set view of the mappings contained in this map. * <p> * Note that this specification strengthens the one given in * {@link Map#entrySet()}. * * @return a set view of the mappings contained in this map. * @see Map#entrySet() */ @Override @SuppressWarnings({"unchecked", "rawtypes"}) default ObjectSet<Map.Entry<K, V>> entrySet() { return (ObjectSet) object2ObjectEntrySet(); } /**
/** * Returns an iterable yielding an iterator that will be * {@linkplain FastEntrySet fast}, if possible, on the * {@linkplain Map#entrySet() entry set} of the provided {@code map}. * * @param map * a map from which we will try to extract an iterable yielding a * (fast) iterator on the entry set. * @return an iterable yielding an iterator on the entry set of the given map * that will be fast, if possible. * @since 8.0.0 */ @SuppressWarnings("unchecked") public static <K, V> ObjectIterable<Object2ObjectMap.Entry<K, V>> fastIterable(Object2ObjectMap<K, V> map) { final ObjectSet<Object2ObjectMap.Entry<K, V>> entries = map.object2ObjectEntrySet(); return entries instanceof Object2ObjectMap.FastEntrySet ? new ObjectIterable<Object2ObjectMap.Entry<K, V>>() { public ObjectIterator<Object2ObjectMap.Entry<K, V>> iterator() { return ((Object2ObjectMap.FastEntrySet<K, V>) entries).fastIterator(); } public void forEach(final Consumer<? super Object2ObjectMap.Entry<K, V>> consumer) { ((Object2ObjectMap.FastEntrySet<K, V>) entries).fastForEach(consumer); } } : entries; } /**
@Nonnull public static <K, V> ObjectIterable<Object2ObjectMap.Entry<K, V>> fastIterable( @Nonnull final Object2ObjectMap<K, V> map) { final ObjectSet<Object2ObjectMap.Entry<K, V>> entries = map.object2ObjectEntrySet(); return entries instanceof Object2ObjectMap.FastEntrySet ? new ObjectIterable<Object2ObjectMap.Entry<K, V>>() { @SuppressWarnings("unchecked") public ObjectIterator<Object2ObjectMap.Entry<K, V>> iterator() { return ((Object2ObjectMap.FastEntrySet<K, V>) entries).fastIterator(); } } : entries; }
@Override public ObjectSet<Object2ObjectMap.Entry<K, V>> object2ObjectEntrySet() { if (entries == null) entries = ObjectSets.unmodifiable(map.object2ObjectEntrySet()); return entries; } /** {@inheritDoc} */
@Override public ObjectSet<Object2ObjectMap.Entry<K, V>> object2ObjectEntrySet() { synchronized (sync) { if (entries == null) entries = ObjectSets.synchronize(map.object2ObjectEntrySet(), sync); return entries; } } /** {@inheritDoc} */
/** * Returns an iterator that will be {@linkplain FastEntrySet fast}, if possible, * on the {@linkplain Map#entrySet() entry set} of the provided {@code map}. * * @param map * a map from which we will try to extract a (fast) iterator on the * entry set. * @return an iterator on the entry set of the given map that will be fast, if * possible. * @since 8.0.0 */ @SuppressWarnings("unchecked") public static <K, V> ObjectIterator<Object2ObjectMap.Entry<K, V>> fastIterator(Object2ObjectMap<K, V> map) { final ObjectSet<Object2ObjectMap.Entry<K, V>> entries = map.object2ObjectEntrySet(); return entries instanceof Object2ObjectMap.FastEntrySet ? ((Object2ObjectMap.FastEntrySet<K, V>) entries).fastIterator() : entries.iterator(); } /**
/** * Iterates {@linkplain FastEntrySet#fastForEach(Consumer) quickly}, if * possible, on the {@linkplain Map#entrySet() entry set} of the provided * {@code map}. * * @param map * a map on which we will try to iterate * {@linkplain FastEntrySet#fastForEach(Consumer) quickly}. * @param consumer * the consumer that will be passed to * {@link FastEntrySet#fastForEach(Consumer)}, if possible, or to * {@link Iterable#forEach(Consumer)}. * @since 8.1.0 */ @SuppressWarnings("unchecked") public static <K, V> void fastForEach(Object2ObjectMap<K, V> map, final Consumer<? super Object2ObjectMap.Entry<K, V>> consumer) { final ObjectSet<Object2ObjectMap.Entry<K, V>> entries = map.object2ObjectEntrySet(); if (entries instanceof Object2ObjectMap.FastEntrySet) ((Object2ObjectMap.FastEntrySet<K, V>) entries).fastForEach(consumer); else entries.forEach(consumer); } /**
/** * Update this permission group manager * * @param currentTimeMS The current system time in milliseconds * @param dT The time that has passed since the last tick in 1/s */ public void update( long currentTimeMS, float dT ) { if ( this.groupMap != null && this.dirty ) { for ( Object2ObjectMap.Entry<String, Group> entry : this.groupMap.object2ObjectEntrySet() ) { if ( entry.getValue() instanceof PermissionGroup ) { ( (PermissionGroup) entry.getValue() ).resetDirty(); } } this.dirty = false; } }