Class ConcurrentSkipListMap.Node<K,​V>

  • Enclosing class:
    ConcurrentSkipListMap<K,​V>

    static final class ConcurrentSkipListMap.Node<K,​V>
    extends java.lang.Object
    Nodes hold keys and values, and are singly linked in sorted order, possibly with some intervening marker nodes. The list is headed by a dummy node accessible as head.node. The value field is declared only as Object because it takes special non-V values for marker and header nodes.
    • Constructor Detail

      • Node

        Node​(ConcurrentSkipListMap.Node<K,​V> next)
        Creates a new marker node. A marker is distinguished by having its value field point to itself. Marker nodes also have null keys, a fact that is exploited in a few places, but this doesn't distinguish markers from the base-level header node (head.node), which also has a null key.
    • Method Detail

      • casValue

        boolean casValue​(java.lang.Object cmp,
                         java.lang.Object val)
        compareAndSet value field
      • isMarker

        boolean isMarker()
        Return true if this node is a marker. This method isn't actually called in an any current code checking for markers because callers will have already read value field and need to use that read (not another done here) and so directly test if value points to node.
        Parameters:
        n - a possibly null reference to a node
        Returns:
        true if this node is a marker node
      • isBaseHeader

        boolean isBaseHeader()
        Return true if this node is the header of base-level list.
        Returns:
        true if this node is header node
      • appendMarker

        boolean appendMarker​(ConcurrentSkipListMap.Node<K,​V> f)
        Tries to append a deletion marker to this node.
        Parameters:
        f - the assumed current successor of this node
        Returns:
        true if successful
      • helpDelete

        void helpDelete​(ConcurrentSkipListMap.Node<K,​V> b,
                        ConcurrentSkipListMap.Node<K,​V> f)
        Helps out a deletion by appending marker or unlinking from predecessor. This is called during traversals when value field seen to be null.
        Parameters:
        b - predecessor
        f - successor
      • getValidValue

        V getValidValue()
        Return value if this node contains a valid key-value pair, else null.
        Returns:
        this node's value if it isn't a marker or header or is deleted, else null.
      • createSnapshot

        ConcurrentSkipListMap.SnapshotEntry<K,​V> createSnapshot()
        Create and return a new SnapshotEntry holding current mapping if this node holds a valid value, else null
        Returns:
        new entry or null