/** * Test that the empty list iterator contract is correct. */ @Override public void testEmptyMapIterator() { fr.inria.diversify.testamplification.logger.Logger.writeTestStart(Thread.currentThread(),this, "testEmptyMapIterator"); if (!(supportsEmptyIterator())) { return ; } super.testEmptyMapIterator(); final OrderedMapIterator<K, V> it = makeEmptyIterator(); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),2694,it,2693,it.hasPrevious()); try { it.previous(); } catch (final NoSuchElementException ex) { } fr.inria.diversify.testamplification.logger.Logger.writeTestFinish(Thread.currentThread()); }
/** * Test that the empty list iterator contract is correct. */ @Test(timeout = 1000) public void testEmptyMapIterator_add949() { fr.inria.diversify.testamplification.logger.Logger.writeTestStart(Thread.currentThread(),this, "testEmptyMapIterator_add949"); if (!(supportsEmptyIterator())) { return ; } super.testEmptyMapIterator(); super.testEmptyMapIterator(); final OrderedMapIterator<K, V> it = makeEmptyIterator(); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),2694,it,2693,it.hasPrevious()); try { it.previous(); } catch (final NoSuchElementException ex) { } fr.inria.diversify.testamplification.logger.Logger.writeTestFinish(Thread.currentThread()); }
/** * Test that the empty list iterator contract is correct. */ @Test(timeout = 1000) public void testEmptyMapIterator_add950() { fr.inria.diversify.testamplification.logger.Logger.writeTestStart(Thread.currentThread(),this, "testEmptyMapIterator_add950"); if (!(supportsEmptyIterator())) { return ; } super.testEmptyMapIterator(); final OrderedMapIterator<K, V> it = makeEmptyIterator(); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),2694,it,2693,it.hasPrevious()); try { it.previous(); it.previous(); } catch (final NoSuchElementException ex) { } fr.inria.diversify.testamplification.logger.Logger.writeTestFinish(Thread.currentThread()); }
/** * {@inheritDoc} */ @Override public OrderedMapIterator<K, V> mapIterator() { if (size == 0) { return EmptyOrderedMapIterator.<K, V>emptyOrderedMapIterator(); } return new LinkMapIterator<K, V>(this); }
/** * Decorates the specified iterator such that it cannot be modified. * * @param <K> the key type * @param <V> the value type * @param iterator the iterator to decorate * @return a new unmodifiable ordered map iterator * @throws NullPointerException if the iterator is null */ public static <K, V> OrderedMapIterator<K, V> unmodifiableOrderedMapIterator( final OrderedMapIterator<K, ? extends V> iterator) { if (iterator == null) { throw new NullPointerException("OrderedMapIterator must not be null"); } if (iterator instanceof Unmodifiable) { @SuppressWarnings("unchecked") // safe to upcast final OrderedMapIterator<K, V> tmpIterator = (OrderedMapIterator<K, V>) iterator; return tmpIterator; } return new UnmodifiableOrderedMapIterator<K, V>(iterator); }
/** * Constructor that decorates the specified iterator. * * @param iterator the iterator to decorate, must not be null * @throws NullPointerException if the iterator is null */ public AbstractOrderedMapIteratorDecorator(final OrderedMapIterator<K, V> iterator) { super(); if (iterator == null) { throw new NullPointerException("OrderedMapIterator must not be null"); } this.iterator = iterator; }
@Override public OrderedMapIterator<K, V> mapIterator() { if (isEmpty()) { return EmptyOrderedMapIterator.<K, V>emptyOrderedMapIterator(); } return new ViewMapIterator(KEY); }
@Override public OrderedMapIterator<V, K> mapIterator() { if (isEmpty()) { return EmptyOrderedMapIterator.<V, K>emptyOrderedMapIterator(); } return new InverseViewMapIterator(VALUE); }
/** * Call only on main thread * @param now Timestamp to calculate if beacon qualifies for removal. * @return Removed beacons count. */ @DebugLog private int removeOldBeacons(long now) { OrderedMapIterator<ID, Beacon> itr = mPublished.mapIterator(); int dead = 0; //Iterates from LRU to MRU. while (itr.hasNext()) { ID id = itr.next(); Beacon beacon = itr.getValue(); if(now - beacon.getLastSeen() > REMOVE) { //TODO force REMOVE > INTERVAL + DURATION ? itr.remove(); mBeacons.remove(id); if(id.getType() == ID.T_TLM) cFramesTLM--; if(cFramesTLM < 0) cFramesTLM = 0; //TODO this should not occur, but did while switching eq_modes updateBeaconDB(id, beacon); mDB.delete("nearby", "_id = ?", new String[]{String.valueOf(beacon.getDbId())}); if(mLogging) { ContentValues cv = beacon.getLogCV(mAppContext); cv.put("event", EVENT_REMOVED_INACTIVE); cv.put("time", now); mDB.insert("log_entries", null, cv); } if(beacon.getOnDisappeared()) sendBroadcast(Const.INTENT_DISAPPEARED, beacon, null); dead++; } else break; //Beacons are sorted LRU to MRU so we can stop at first non-removable beacon. } return dead; }
/** * Test that the empty list iterator contract is correct. */ @Test(timeout = 1000) public void testEmptyMapIterator_remove721() { fr.inria.diversify.testamplification.logger.Logger.writeTestStart(Thread.currentThread(),this, "testEmptyMapIterator_remove721"); if (!(supportsEmptyIterator())) { return ; } final OrderedMapIterator<K, V> it = makeEmptyIterator(); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),2694,it,2693,it.hasPrevious()); try { it.previous(); } catch (final NoSuchElementException ex) { } fr.inria.diversify.testamplification.logger.Logger.writeTestFinish(Thread.currentThread()); }
public void testDecorateFactory() { fr.inria.diversify.testamplification.logger.Logger.writeTestStart(Thread.currentThread(),this, "testDecorateFactory"); OrderedMapIterator<K, V> it = makeObject(); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),4397,it); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),4399,null,4398,org.apache.commons.collections4.iterators.UnmodifiableOrderedMapIterator.unmodifiableOrderedMapIterator(it)); it = getMap().mapIterator(); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),4400,(it != (org.apache.commons.collections4.iterators.UnmodifiableOrderedMapIterator.unmodifiableOrderedMapIterator(it)))); try { org.apache.commons.collections4.iterators.UnmodifiableOrderedMapIterator.unmodifiableOrderedMapIterator(null); } catch (final IllegalArgumentException ex) { } fr.inria.diversify.testamplification.logger.Logger.writeTestFinish(Thread.currentThread()); }
@Test(timeout = 1000) public void testDecorateFactory_add1217() { fr.inria.diversify.testamplification.logger.Logger.writeTestStart(Thread.currentThread(),this, "testDecorateFactory_add1217"); OrderedMapIterator<K, V> it = makeObject(); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),4397,it); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),4399,null,4398,org.apache.commons.collections4.iterators.UnmodifiableOrderedMapIterator.unmodifiableOrderedMapIterator(it)); it = getMap().mapIterator(); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),4400,(it != (org.apache.commons.collections4.iterators.UnmodifiableOrderedMapIterator.unmodifiableOrderedMapIterator(it)))); try { org.apache.commons.collections4.iterators.UnmodifiableOrderedMapIterator.unmodifiableOrderedMapIterator(null); org.apache.commons.collections4.iterators.UnmodifiableOrderedMapIterator.unmodifiableOrderedMapIterator(null); } catch (final IllegalArgumentException ex) { } fr.inria.diversify.testamplification.logger.Logger.writeTestFinish(Thread.currentThread()); }
/** * Makes sure that it gives priority to recent mesos slaves * (LRU algorithm) if its present in offers list. * This will help in reducing build time since all the required * artifacts will be present already. * @param offers */ private void reArrangeOffersBasedOnAffinity(List<Offer> offers) { if(recentlyAcceptedOffers.size() > 0) { //Iterates from least to most recently used. OrderedMapIterator<String, Object> mapIterator = recentlyAcceptedOffers.mapIterator(); while (mapIterator.hasNext()) { String recentSlaveId = mapIterator.next(); reArrangeOffersBasedOnAffinity(offers, recentSlaveId); } } }
/** * {@inheritDoc} */ public OrderedMapIterator<K, V> mapIterator() { return new SingletonMapIterator<K, V>(this); }
@Override public OrderedMapIterator<K, V> mapIterator() { return decorated().mapIterator(); }
@Override public OrderedMapIterator<K, V> mapIterator() { return new ListOrderedMapIterator<K, V>(this); }
/** * {@inheritDoc} */ @Override public OrderedMapIterator<K, V> mapIterator() { return new SortedMapIterator<K, V>(entrySet()); }
@Override public OrderedMapIterator<K, V> mapIterator() { final OrderedMapIterator<K, V> it = decorated().mapIterator(); return UnmodifiableOrderedMapIterator.unmodifiableOrderedMapIterator(it); }
public OrderedMapIterator<K, V> mapIterator() { return new TrieMapIterator(); }
public OrderedMapIterator<K, V> mapIterator() { final OrderedMapIterator<K, V> it = delegate.mapIterator(); return UnmodifiableOrderedMapIterator.unmodifiableOrderedMapIterator(it); }
@Override public OrderedMapIterator<K, V> makeEmptyIterator() { resetEmpty(); return org.apache.commons.collections4.map.AbstractOrderedMapTest.this.getMap().mapIterator(); }
@Override public OrderedMapIterator<K, V> makeObject() { resetFull(); return org.apache.commons.collections4.map.AbstractOrderedMapTest.this.getMap().mapIterator(); }