Class: WirisPlugin::SortedHash

Inherits:
HashT
  • Object
show all
Includes:
Wiris
Defined in:
lib/com/wiris/util/type/SortedHash.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSortedHash

Returns a new instance of SortedHash.



8
9
10
11
# File 'lib/com/wiris/util/type/SortedHash.rb', line 8

def initialize()
    super()
    self.sortedKeys = Array.new()
end

Instance Attribute Details

#sortedKeysObject

Returns the value of attribute sortedKeys.



7
8
9
# File 'lib/com/wiris/util/type/SortedHash.rb', line 7

def sortedKeys
  @sortedKeys
end

Instance Method Details

#getSortedKeysObject



28
29
30
# File 'lib/com/wiris/util/type/SortedHash.rb', line 28

def getSortedKeys()
    return self.sortedKeys
end

#keysObject



25
26
27
# File 'lib/com/wiris/util/type/SortedHash.rb', line 25

def keys()
    return self.sortedKeys::iterator()
end

#push(key, value, limit) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/com/wiris/util/type/SortedHash.rb', line 31

def push(key, value, limit)
    idx = Arrays::indexOfElement(self.sortedKeys,key)
    if idx >= 0
        self.sortedKeys::splice(idx,1)
        self.sortedKeys::push(key)
    else 
        if ((limit >= 0) && (self.sortedKeys::length() > 0)) && (self.sortedKeys::length() >= limit)
            self.remove(self.sortedKeys::_(0))
        end
        self.set(key,value)
    end
end

#remove(key) ⇒ Object



21
22
23
24
# File 'lib/com/wiris/util/type/SortedHash.rb', line 21

def remove(key)
    self.sortedKeys::remove(key)
    return super(key)
end

#set(key, value) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/com/wiris/util/type/SortedHash.rb', line 12

def set(key, value)
    i = Arrays::indexOfElement(self.sortedKeys,key)
    if i >= 0
        self.sortedKeys::_(i,key)
    else 
        self.sortedKeys::push(key)
    end
    super(key,value)
end