1
0
Fork 0
mirror of https://github.com/haml/haml.git synced 2022-11-09 12:33:31 -05:00

[Sass] Get rid of the now-unused OrderedHash.

This commit is contained in:
Nathan Weizenbaum 2009-05-10 14:23:48 -07:00
parent 08afa18cde
commit 1dc8325d3f

View file

@ -42,61 +42,6 @@ module Sass
end
end
# This class is based on the Ruby 1.9 ordered hashes.
# It keeps the semantics and most of the efficiency of normal hashes
# while also keeping track of the order in which elements were set.
class OrderedHash
Node = Struct.new(:key, :value, :next, :prev)
include Enumerable
def initialize
@hash = {}
end
def initialize_copy(other)
@hash = other.instance_variable_get('@hash').clone
end
def [](key)
@hash[key] && @hash[key].value
end
def []=(key, value)
node = Node.new(key, value)
if old = @hash[key]
if old.prev
old.prev.next = old.next
else # old is @first and @last
@first = @last = nil
end
end
if @first.nil?
@first = @last = node
else
node.prev = @last
@last.next = node
@last = node
end
@hash[key] = node
value
end
def each
return unless @first
yield [@first.key, @first.value]
node = @first
yield [node.key, node.value] while node = node.next
self
end
def values
self.map { |k, v| v }
end
end
# :startdoc:
# This class contains the functionality used in the +css2sass+ utility,