Class: WirisPlugin::HashCache
- Inherits:
-
HashT
- Object
- HashT
- WirisPlugin::HashCache
- Includes:
- Wiris
- Defined in:
- lib/com/wiris/util/type/HashCache.rb
Instance Attribute Summary collapse
-
#maxSize ⇒ Object
Returns the value of attribute maxSize.
-
#sortedKeys ⇒ Object
Returns the value of attribute sortedKeys.
Instance Method Summary collapse
- #getMaxSize ⇒ Object
- #getSortedKeys ⇒ Object
-
#initialize(maxSize) ⇒ HashCache
constructor
A new instance of HashCache.
- #keys ⇒ Object
- #remove(key) ⇒ Object
- #set(key, value) ⇒ Object
- #setMaxSize(maxSize) ⇒ Object
Constructor Details
Instance Attribute Details
#maxSize ⇒ Object
Returns the value of attribute maxSize.
6 7 8 |
# File 'lib/com/wiris/util/type/HashCache.rb', line 6 def maxSize @maxSize end |
#sortedKeys ⇒ Object
Returns the value of attribute sortedKeys.
7 8 9 |
# File 'lib/com/wiris/util/type/HashCache.rb', line 7 def sortedKeys @sortedKeys end |
Instance Method Details
#getMaxSize ⇒ Object
13 14 15 |
# File 'lib/com/wiris/util/type/HashCache.rb', line 13 def getMaxSize() return self.maxSize end |
#getSortedKeys ⇒ Object
19 20 21 |
# File 'lib/com/wiris/util/type/HashCache.rb', line 19 def getSortedKeys() return self.sortedKeys end |
#keys ⇒ Object
28 29 30 |
# File 'lib/com/wiris/util/type/HashCache.rb', line 28 def keys() return self.sortedKeys::iterator() end |
#remove(key) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/com/wiris/util/type/HashCache.rb', line 22 def remove(key) if self.sortedKeys::remove(key) return super(key) end return false end |
#set(key, value) ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/com/wiris/util/type/HashCache.rb', line 31 def set(key, value) if (self.sortedKeys != nil) && (self.sortedKeys::length() >= self.maxSize) removed = self.sortedKeys::_(0) if self.sortedKeys::remove(removed) super(removed) end end self.sortedKeys::push(key) super(key,value) end |
#setMaxSize(maxSize) ⇒ Object
16 17 18 |
# File 'lib/com/wiris/util/type/HashCache.rb', line 16 def setMaxSize(maxSize) self.maxSize = maxSize end |