/** * Removes the element at the specified index. * * @param index the index of the object to remove * @return the previous value corresponding the <code>key</code>, * or <code>null</code> if none existed * @throws IndexOutOfBoundsException if the index is invalid */ public Object remove(int index) { return remove(get(index)); }
public int lastIndexOf(Object obj) { return parent.indexOf(obj); }
/** * Gets the index of the specified key. * * @param key the key to find the index of * @return the index, or -1 if not found */ public int indexOf(Object key) { key = convertKey(key); int i = 0; for (LinkEntry entry = header.after; entry != header; entry = entry.after, i++) { if (isEqualKey(key, entry.key)) { return i; } } return -1; }
public void setSavepoint(String name) { beginOperation(true); try { assertActiveTransaction(); if (_savepoints != null && _savepoints.containsKey(name)) throw new UserException(_loc.get("savepoint-exists", name)); if (hasFlushed() && !_spm.supportsIncrementalFlush()) throw new UnsupportedException(_loc.get ("savepoint-flush-not-supported")); OpenJPASavepoint save = _spm.newSavepoint(name, this); if (_savepoints == null || _savepoints.isEmpty()) { save.save(getTransactionalStates()); _savepoints = new LinkedMap(); } else { if (_savepointCache == null) save.save(Collections.EMPTY_SET); else { save.save(_savepointCache); _savepointCache.clear(); } } _savepoints.put(name, save); } catch (OpenJPAException ke) { throw ke; } catch (Exception e) { throw new GeneralException(e); } finally { endOperation(); } }
LinkedMap lm = (LinkedMap) map; try { lm.remove(0); } catch (IndexOutOfBoundsException ex) {} try { lm.remove(-1); } catch (IndexOutOfBoundsException ex) {} lm = (LinkedMap) map; try { lm.remove(-1); } catch (IndexOutOfBoundsException ex) {} try { lm.remove(lm.size()); } catch (IndexOutOfBoundsException ex) {} for (MapIterator it = lm.mapIterator(); it.hasNext();) { list.add(it.next()); Object value = lm.get(key); assertEquals(value, lm.remove(i)); list.remove(i); assertEquals(false, lm.containsKey(key));
parameterTypes = new LinkedMap(6); if (!parameterTypes.containsKey(id)) parameterTypes.put(id, TYPE_OBJECT); } else { index = parameterTypes.indexOf(id);
fetcher.waitUntilRun(); assertEquals(0, consumer.getPendingOffsetsToCommit().size()); assertEquals(1, consumer.getPendingOffsetsToCommit().size()); assertEquals(state1, consumer.getPendingOffsetsToCommit().get(138L)); assertEquals(2, consumer.getPendingOffsetsToCommit().size()); assertEquals(state2, consumer.getPendingOffsetsToCommit().get(140L)); assertEquals(1, consumer.getPendingOffsetsToCommit().size()); assertTrue(consumer.getPendingOffsetsToCommit().containsKey(140L)); assertEquals(state1, fetcher.getAndClearLastCommittedOffsets()); assertEquals(1, fetcher.getCommitCount()); assertEquals(2, consumer.getPendingOffsetsToCommit().size()); assertEquals(state3, consumer.getPendingOffsetsToCommit().get(141L)); assertEquals(0, consumer.getPendingOffsetsToCommit().size()); assertEquals(state3, fetcher.getAndClearLastCommittedOffsets()); assertEquals(2, fetcher.getCommitCount()); assertEquals(0, consumer.getPendingOffsetsToCommit().size()); assertNull(fetcher.getAndClearLastCommittedOffsets()); assertEquals(2, fetcher.getCommitCount());
public Map makeEmptyMap() { return new LinkedMap(); }
public void testGetByIndex() { resetEmpty(); LinkedMap lm = (LinkedMap) map; try { lm.get(0); } catch (IndexOutOfBoundsException ex) {} try { lm.get(-1); } catch (IndexOutOfBoundsException ex) {} resetFull(); lm = (LinkedMap) map; try { lm.get(-1); } catch (IndexOutOfBoundsException ex) {} try { lm.get(lm.size()); } catch (IndexOutOfBoundsException ex) {} int i = 0; for (MapIterator it = lm.mapIterator(); it.hasNext(); i++) { assertSame(it.next(), lm.get(i)); } }
public void addChildWindow(HstComponentWindow child) { if (this.childWindowMap == null) { this.childWindowMap = new LinkedMap(); } HstComponentWindow old = (HstComponentWindow) this.childWindowMap.put(child.getName(), child); if (old != null) { log.error("Ambiguous components configuration because component sibblings found with same name: '{}'. " + "The first one is replaced. This should not be possible. You can report the HST2 team so they can fix this.", child.getName() ); } if (this.childWindowMapByReferenceName == null) { this.childWindowMapByReferenceName = new LinkedMap(); } this.childWindowMapByReferenceName.put(child.getReferenceName(), child); }
/** * Insert a replica into an evictable map. * * If an element already exists with this eviction time, we add a nanosecond * to it until we find an unused key. * * @param evictionTimeNs The eviction time in absolute nanoseconds. * @param replica The replica to insert. * @param map The map to insert it into. */ private void insertEvictable(Long evictionTimeNs, ShortCircuitReplica replica, LinkedMap map) { while (map.containsKey(evictionTimeNs)) { evictionTimeNs++; } Preconditions.checkState(null == replica.getEvictableTimeNs()); replica.setEvictableTimeNs(evictionTimeNs); map.put(evictionTimeNs, replica); }
public Object get(int index) { return parent.get(index); }
public boolean contains(Object obj) { return parent.containsKey(obj); }