lru_redux 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4e9a008051600ae0ef7295fcbd1826f9577e9651
4
- data.tar.gz: 92cfb4d20f44bf999b1bfd113dc517ed902af2d3
3
+ metadata.gz: 78eae8fc324be527cb810fa0346fc009f4bee816
4
+ data.tar.gz: dcc9a4af9681636d338ebdeca2e2eef99152dd06
5
5
  SHA512:
6
- metadata.gz: 7687af703aec4575050e5bff2f2e4d0f7d50137e427f3b1ef734de963b39ef291950afe023b448a7d9a27f175b38efacbccdd4d149d153b24e745b3af2e66004
7
- data.tar.gz: ef7357e9b3c1940ccc6552c261e906094bb1065bfc38eccae83db8386d564f0bb425ae0a91b834c77b7fec2e5dca58ef6ca1edfa05ce02139e58579433e2843e
6
+ metadata.gz: 8c55ef7737644cdc0bdc25abbb3d4756eeef996e179ec31871f22925abd370c43e6070b513cf6bbc82afb31782430534111a32f2fab31a576d0892b8fef87241
7
+ data.tar.gz: f11d972cd374a60163cf0430d6727755bb652a490fec1a0b36de96045faf35c5b7fab45ef8598f3a3223253141f851135e86cb23c741a6eee64bff854172f1b4
data/README.md CHANGED
@@ -69,3 +69,9 @@ lru_redux thread safe 2.750000 0.000000 2.750000 ( 2.752526)
69
69
  3. Commit your changes (`git commit -am 'Add some feature'`)
70
70
  4. Push to the branch (`git push origin my-new-feature`)
71
71
  5. Create new Pull Request
72
+
73
+ ## Changlog
74
+
75
+ ###verson 0.0.2 - 23-April-2013
76
+
77
+ - Added .clear method
@@ -3,8 +3,8 @@ class LruRedux::Cache
3
3
  # for high efficiency nodes in double linked list are stored in arrays
4
4
  # [prev,key,val,next]
5
5
 
6
- def initialize(size)
7
- @size = size
6
+ def initialize(max_size)
7
+ @max_size = max_size
8
8
  @data = {}
9
9
  @head = nil
10
10
  @tail = nil
@@ -62,6 +62,11 @@ class LruRedux::Cache
62
62
  end
63
63
  end
64
64
 
65
+ def clear
66
+ @data.clear
67
+ @head = @tail = nil
68
+ end
69
+
65
70
  def count
66
71
  @data.count
67
72
  end
@@ -108,7 +113,7 @@ class LruRedux::Cache
108
113
  end
109
114
 
110
115
  def pop_tail
111
- if @data.length == @size
116
+ if @data.length == @max_size
112
117
  @data.delete(@tail.key)
113
118
  @tail = @tail.next
114
119
  @tail.prev = nil
@@ -1,3 +1,3 @@
1
1
  module LruRedux
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/test/cache_test.rb CHANGED
@@ -47,4 +47,13 @@ class CacheTest < MiniTest::Unit::TestCase
47
47
  @c[:a] = 99
48
48
  assert_equal [[:a,99],[:c,3],[:b,2]], @c.to_a
49
49
  end
50
+
51
+ def test_clear
52
+ @c[:a] = 1
53
+ @c[:b] = 2
54
+ @c[:c] = 3
55
+
56
+ @c.clear
57
+ assert_equal [], @c.to_a
58
+ end
50
59
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lru_redux
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Saffron