Class: Gap::HashChain::HashNode
- Inherits:
-
Struct
- Object
- Struct
- Gap::HashChain::HashNode
- Defined in:
- lib/gap50/cache/hashchain.rb,
lib/gap50/cache/hashchain.rb
Instance Attribute Summary collapse
-
#hash ⇒ Object
Returns the value of attribute hash.
-
#next ⇒ Object
Returns the value of attribute next.
-
#usagetag ⇒ Object
Returns the value of attribute usagetag.
Instance Method Summary collapse
- #[](a) ⇒ Object
- #[]=(a, b) ⇒ Object
- #delete(a) ⇒ Object
- #deleteAll(a) ⇒ Object
- #get(a) ⇒ Object
- #getone(a) ⇒ Object
- #include?(a) ⇒ Boolean
-
#initialize(hash = {}, nx = nil) ⇒ HashNode
constructor
A new instance of HashNode.
- #set(a, b) ⇒ Object
- #usage ⇒ Object
Constructor Details
#initialize(hash = {}, nx = nil) ⇒ HashNode
Returns a new instance of HashNode.
33 34 35 |
# File 'lib/gap50/cache/hashchain.rb', line 33 def initialize(hash = {}, nx = nil) super(hash, nx) end |
Instance Attribute Details
#hash ⇒ Object
Returns the value of attribute hash
3 4 5 |
# File 'lib/gap50/cache/hashchain.rb', line 3 def hash @hash end |
#next ⇒ Object
Returns the value of attribute next
3 4 5 |
# File 'lib/gap50/cache/hashchain.rb', line 3 def next @next end |
#usagetag ⇒ Object
Returns the value of attribute usagetag.
32 33 34 |
# File 'lib/gap50/cache/hashchain.rb', line 32 def usagetag @usagetag end |
Instance Method Details
#[](a) ⇒ Object
61 62 63 64 |
# File 'lib/gap50/cache/hashchain.rb', line 61 def [](a) return usage.call(self)[a] if usage get a end |
#[]=(a, b) ⇒ Object
67 68 69 70 |
# File 'lib/gap50/cache/hashchain.rb', line 67 def []=(a, b) return (usage.call(self)[a] = b) if usage set a, b end |
#delete(a) ⇒ Object
83 84 85 86 |
# File 'lib/gap50/cache/hashchain.rb', line 83 def delete(a) return (usage.call(self).delete(a)) if usage self.hash.delete a end |
#deleteAll(a) ⇒ Object
88 89 90 91 92 |
# File 'lib/gap50/cache/hashchain.rb', line 88 def deleteAll(a) return (usage.call(self).deleteAll(a)) if usage self.hash.delete a self.next.deleteAll a if self.next end |
#get(a) ⇒ Object
47 48 49 50 51 52 53 54 55 |
# File 'lib/gap50/cache/hashchain.rb', line 47 def get(a) if self.hash.include?(a) self.hash[a] elsif self.next self.next[a] else nil end end |
#getone(a) ⇒ Object
43 44 45 |
# File 'lib/gap50/cache/hashchain.rb', line 43 def getone(a) self.hash[a] end |
#include?(a) ⇒ Boolean
72 73 74 75 76 77 78 79 80 81 |
# File 'lib/gap50/cache/hashchain.rb', line 72 def include?(a) return (usage.call(self).include?(a)) if usage if self.hash.include?(a) true elsif self.next self.next.include?(a) else false end end |
#set(a, b) ⇒ Object
57 58 59 |
# File 'lib/gap50/cache/hashchain.rb', line 57 def set(a, b) self.hash[a] = b end |
#usage ⇒ Object
37 38 39 40 41 |
# File 'lib/gap50/cache/hashchain.rb', line 37 def usage if self.usagetag USAGE[self.usagetag] end end |