/** * Returns a key-value mapping associated with the least * key in this map, or <tt>null</tt> if the map is empty. * The returned entry does <em>not</em> support * the <tt>Entry.setValue</tt> method. * * @return an Entry with least key, or <tt>null</tt> * if the map is empty. */ public Map.Entry<K,V> firstEntry() { for (;;) { Node<K,V> n = findFirst(); if (n == null) return null; SnapshotEntry<K,V> e = n.createSnapshot(); if (e != null) return e; } }
/** * Returns a key-value mapping associated with the greatest * key in this map, or <tt>null</tt> if the map is empty. * The returned entry does <em>not</em> support * the <tt>Entry.setValue</tt> method. * * @return an Entry with greatest key, or <tt>null</tt> * if the map is empty. */ public Map.Entry<K,V> lastEntry() { for (;;) { Node<K,V> n = findLast(); if (n == null) return null; SnapshotEntry<K,V> e = n.createSnapshot(); if (e != null) return e; } }
/** * Return SnapshotEntry for results of findNear. * @param kkey the key * @param rel the relation -- OR'ed combination of EQ, LT, GT * @return Entry fitting relation, or null if no such */ SnapshotEntry<K,V> getNear(K kkey, int rel) { for (;;) { Node<K,V> n = findNear(kkey, rel); if (n == null) return null; SnapshotEntry<K,V> e = n.createSnapshot(); if (e != null) return e; } }
public Map.Entry<K,V> lastEntry() { for (;;) { ConcurrentSkipListMap.Node<K,V> n = lastNode(); if (n == null || !inHalfOpenRange(n.key)) return null; Map.Entry<K,V> e = n.createSnapshot(); if (e != null) return e; } }
public Map.Entry<K,V> firstEntry() { for (;;) { ConcurrentSkipListMap.Node<K,V> n = firstNode(); if (!isBeforeEnd(n)) return null; Map.Entry<K,V> e = n.createSnapshot(); if (e != null) return e; } }