class Concurrent::LockFreeStack
@!macro warn.edge
def self.of1(value)
def self.of1(value) new Node[value, EMPTY] end
def self.of2(value1, value2)
def self.of2(value1, value2) new Node[value1, Node[value2, EMPTY]] end
def clear
-
(true, false)
-
def clear while true current_head = head return false if current_head == EMPTY return true if compare_and_set_head current_head, EMPTY end end
def clear_each(&block)
- Yieldparam: value -
Other tags:
- Yield: - over the cleared stack
Returns:
-
(self)
-
def clear_each(&block) while true current_head = head return self if current_head == EMPTY if compare_and_set_head current_head, EMPTY each current_head, &block return self end end end
def clear_if(head)
-
(true, false)
-
Parameters:
-
head
(Node
) --
def clear_if(head) compare_and_set_head head, EMPTY end
def compare_and_clear(head)
-
(true, false)
-
Parameters:
-
head
(Node
) --
def compare_and_clear(head) compare_and_set_head head, EMPTY end
def compare_and_pop(head)
-
(true, false)
-
Parameters:
-
head
(Node
) --
def compare_and_pop(head) compare_and_set_head head, head.next_node end
def compare_and_push(head, value)
-
(true, false)
-
Parameters:
-
value
(Object
) -- -
head
(Node
) --
def compare_and_push(head, value) compare_and_set_head head, Node[value, head] end
def each(head = nil)
-
(self)
-
Parameters:
-
head
(Node
) --
def each(head = nil) return to_enum(:each, head) unless block_given? it = head || peek until it.equal?(EMPTY) yield it.value it = it.next_node end self end
def empty?(head = head())
-
(true, false)
-
Parameters:
-
head
(Node
) --
def empty?(head = head()) head.equal? EMPTY end
def initialize(head = EMPTY)
-
head
(Node
) --
def initialize(head = EMPTY) super() self.head = head end
def peek
-
(Node)
-
def peek head end
def pop
-
(Object)
-
def pop while true current_head = head return current_head.value if compare_and_set_head current_head, current_head.next_node end end
def push(value)
-
(self)
-
Parameters:
-
value
(Object
) --
def push(value) while true current_head = head return self if compare_and_set_head current_head, Node[value, current_head] end end
def replace_if(head, new_head)
-
(true, false)
-
Parameters:
-
new_head
(Node
) -- -
head
(Node
) --
def replace_if(head, new_head) compare_and_set_head head, new_head end
def to_s
-
(String)
- Short string representation.
def to_s format '%s %s>', super[0..-2], to_a.to_s end