module Doku::DancingLinks::HorizontalLinks
This module is mixed into objects to give them their “left” and “right” links, and to give some convenient methods for changing those links. Every class this module is added to gains to attr_accessors: left and right.
Public Class Methods
# File lib/doku/dancing_links.rb, line 68 def self.included(klass) klass.instance_eval do attr_accessor :left, :right end end
Public Instance Methods
Inserts this object to the left of the specified object in the horizontal list.
# File lib/doku/dancing_links.rb, line 92 def insert_left(obj) self.left, self.right = obj.left, obj reinsert_horizontal end
Reinserts this object into the horizontal linked list by making the former left and right neighors point to this object instead of each other. The former left and right neighbors are simply found by looking at the “left” and “right” links for this object, which still point to them. This undoes the effect of {#remove_horizontal}.
# File lib/doku/dancing_links.rb, line 86 def reinsert_horizontal left.right = right.left = self end
Removes this object from the horizontal linked list by making the left and right neighbors point at each other instead of this object. This can later be undone with {#reinsert_horizontal}
# File lib/doku/dancing_links.rb, line 77 def remove_horizontal right.left, left.right = left, right end