sized_list 0.2.5 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MGQ4OWZhMGJlZGE1ZTY4ZWZlMWRhMDNlN2Y1MzBjMDdkZTRmYmI0Nw==
5
+ data.tar.gz: !binary |-
6
+ MGRjZWRmYTAyMGU2OWZiZWU1MjkyYzBjYTRmMmNlYzMxNzRhNDlkYQ==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ MzVkYTEyNzZhYWY3ZTYwYjRkMzc5ZWUwNGMyNjEyZTBlMDljZDliOTgwNzdi
10
+ NmY2MjAwNzkyZWQ2YzJkNjhkZjIwOWRkYWY1MjhiZDM5N2NkZDUzZTRmYWMz
11
+ M2JmYWU4MzZmNzJhZGJmZjZiZTIwM2JkZjFlNTkzYjk0ODI5NDI=
12
+ data.tar.gz: !binary |-
13
+ OGEwMDNjY2FkMTMyOWMwYzEyNDM5ZDFiMjY2ZDI0MGUxM2QwODUxY2VlZGYw
14
+ M2FiZDVkYWQwNDgwMzU4OTNhNzA4MzIwMWY1OTAxOTM0MzY3ZWYzY2U0ZDBj
15
+ MTU1OTkzYjM5YWQ0N2NmZTQ3MWVhMTJkOTRlNjRjNjI0MzFmMDA=
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.5
1
+ 0.2.6
data/lib/sized_list.rb CHANGED
@@ -14,7 +14,6 @@ class SizedList
14
14
 
15
15
  def initialize(max_size)
16
16
  @max_size = max_size
17
- @used = []
18
17
  @items = {}
19
18
  self.reset_stats
20
19
  end
@@ -55,10 +54,7 @@ class SizedList
55
54
  alias []= set
56
55
 
57
56
  def delete(key)
58
- if self.exist?(key)
59
- @used.reject! { |k| k == key }
60
- @items.delete key
61
- end
57
+ @items.delete key
62
58
  end
63
59
 
64
60
  def each
@@ -72,7 +68,7 @@ class SizedList
72
68
  end
73
69
 
74
70
  def keys
75
- @used
71
+ @items.keys
76
72
  end
77
73
 
78
74
  def values
@@ -95,15 +91,10 @@ class SizedList
95
91
 
96
92
  private
97
93
 
94
+ # Bump the specified k/v pair to the end of the list,
95
+ # marking it as least-recently-used.
98
96
  def used!(key)
99
- if @used.first == key
100
- # no-op
101
- elsif @used.last == key
102
- @used.unshift @used.pop
103
- else
104
- @used.reject! { |k| k == key }
105
- @used.unshift key
106
- end
97
+ @items[key] = @items.delete(key)
107
98
  end
108
99
 
109
100
  def remove_least_recently_used!
@@ -118,7 +109,6 @@ class SizedList
118
109
  @last_evicted_at = now
119
110
  end
120
111
 
121
- key = @used.pop
122
- @items.delete key
112
+ @items.delete @items.first[0]
123
113
  end
124
114
  end
data/sized_list.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{sized_list}
8
- s.version = "0.2.5"
8
+ s.version = "0.2.6"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Doug Youch"]
@@ -18,17 +18,17 @@ describe SizedList do
18
18
  list['c'] = 1
19
19
  list['d'] = 1
20
20
  list['e'] = 1
21
- list.keys.should == ['e', 'd', 'c', 'b', 'a']
21
+ list.keys.should == ['a', 'b', 'c', 'd', 'e']
22
22
 
23
23
  list['b'].should == 1
24
- list.keys.should == ['b', 'e', 'd', 'c', 'a']
24
+ list.keys.should == ['a', 'c', 'd', 'e', 'b']
25
25
  list.evictions.should == 0
26
26
  list.misses.should == 0
27
27
  list.hits.should == 1
28
28
  list.writes.should == 5
29
29
 
30
30
  list['b'].should == 1
31
- list.keys.should == ['b', 'e', 'd', 'c', 'a']
31
+ list.keys.should == ['a', 'c', 'd', 'e', 'b']
32
32
  list.evictions.should == 0
33
33
  list.misses.should == 0
34
34
  list.hits.should == 2
@@ -47,27 +47,27 @@ describe SizedList do
47
47
  list['c'] = 1
48
48
  list['d'] = 1
49
49
  list['e'] = 1
50
- list.keys.should == ['e', 'd', 'c', 'b', 'a']
50
+ list.keys.should == ['a', 'b', 'c', 'd', 'e']
51
51
  list.writes.should == 5
52
52
 
53
53
  list['a'].should == 1
54
- list.keys.should == ['a', 'e', 'd', 'c', 'b']
54
+ list.keys.should == ['b', 'c', 'd', 'e', 'a']
55
55
  list.evictions.should == 0
56
56
 
57
57
  list['new'] = 1
58
58
  list.evicted?.should be_true
59
59
  list['new'] = 1
60
60
  list.evicted?.should be_false
61
- list.keys.should == ['new', 'a', 'e', 'd', 'c']
61
+ list.keys.should == ['c', 'd', 'e', 'a', 'new']
62
62
  list.evictions.should == 1
63
63
  list.writes.should == 6
64
64
 
65
65
  list['d'].should == 1
66
- list.keys.should == ['d', 'new', 'a', 'e', 'c']
66
+ list.keys.should == ['c', 'e', 'a', 'new', 'd']
67
67
  list.evictions.should == 1
68
68
 
69
69
  list['new2'] = 1
70
- list.keys.should == ['new2', 'd', 'new', 'a', 'e']
70
+ list.keys.should == ['e', 'a', 'new', 'd', 'new2']
71
71
  list.evictions.should == 2
72
72
  end
73
73
  end
metadata CHANGED
@@ -1,71 +1,65 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: sized_list
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 2
8
- - 5
9
- version: 0.2.5
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.6
10
5
  platform: ruby
11
- authors:
6
+ authors:
12
7
  - Doug Youch
13
8
  autorequire:
14
9
  bindir: bin
15
10
  cert_chain: []
16
-
17
- date: 2013-05-22 00:00:00 -04:00
18
- default_executable:
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
21
- prerelease: false
22
- type: :development
11
+ date: 2013-05-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
23
14
  name: rdoc
24
- version_requirements: &id001 !ruby/object:Gem::Requirement
25
- requirements:
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
26
17
  - - ~>
27
- - !ruby/object:Gem::Version
28
- segments:
29
- - 3
30
- - 12
31
- version: "3.12"
32
- requirement: *id001
33
- - !ruby/object:Gem::Dependency
34
- prerelease: false
18
+ - !ruby/object:Gem::Version
19
+ version: '3.12'
35
20
  type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '3.12'
27
+ - !ruby/object:Gem::Dependency
36
28
  name: jeweler
37
- version_requirements: &id002 !ruby/object:Gem::Requirement
38
- requirements:
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
39
31
  - - ~>
40
- - !ruby/object:Gem::Version
41
- segments:
42
- - 1
43
- - 8
44
- - 4
32
+ - !ruby/object:Gem::Version
45
33
  version: 1.8.4
46
- requirement: *id002
47
- - !ruby/object:Gem::Dependency
48
- prerelease: false
49
34
  type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: 1.8.4
41
+ - !ruby/object:Gem::Dependency
50
42
  name: rspec
51
- version_requirements: &id003 !ruby/object:Gem::Requirement
52
- requirements:
53
- - - ">="
54
- - !ruby/object:Gem::Version
55
- segments:
56
- - 0
57
- version: "0"
58
- requirement: *id003
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
59
55
  description: Uses LRU functionality to keep a limited size list of items
60
56
  email: doug@sessionm.com
61
57
  executables: []
62
-
63
58
  extensions: []
64
-
65
- extra_rdoc_files:
59
+ extra_rdoc_files:
66
60
  - LICENSE.txt
67
61
  - README.rdoc
68
- files:
62
+ files:
69
63
  - .document
70
64
  - Gemfile
71
65
  - Gemfile.lock
@@ -78,35 +72,28 @@ files:
78
72
  - sized_list.gemspec
79
73
  - spec/sized_list_spec.rb
80
74
  - spec/spec_helper.rb
81
- has_rdoc: true
82
75
  homepage: http://github.com/dyouch5@yahoo.com/sized_list
83
- licenses:
76
+ licenses:
84
77
  - MIT
78
+ metadata: {}
85
79
  post_install_message:
86
80
  rdoc_options: []
87
-
88
- require_paths:
81
+ require_paths:
89
82
  - lib
90
- required_ruby_version: !ruby/object:Gem::Requirement
91
- requirements:
92
- - - ">="
93
- - !ruby/object:Gem::Version
94
- segments:
95
- - 0
96
- version: "0"
97
- required_rubygems_version: !ruby/object:Gem::Requirement
98
- requirements:
99
- - - ">="
100
- - !ruby/object:Gem::Version
101
- segments:
102
- - 0
103
- version: "0"
83
+ required_ruby_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ required_rubygems_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ! '>='
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
104
93
  requirements: []
105
-
106
94
  rubyforge_project:
107
- rubygems_version: 1.3.6
95
+ rubygems_version: 2.2.2
108
96
  signing_key:
109
97
  specification_version: 3
110
98
  summary: Limited size list
111
99
  test_files: []
112
-