searchractor 1.0.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/searchractor.rb +23 -1
  3. metadata +21 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c214730fc323757a97bb2bf3c7760dac861ae0f5f5bcf1aedd8656552a31b9ce
4
- data.tar.gz: 784c9987987134e1b8c72d9edd5368b77f3b7ee0574194b03d680d6449fbfe64
3
+ metadata.gz: 1a9ea3d87b80a774a0390868af20b34fd08e34d2a16cd762f8a5bf3d8e329141
4
+ data.tar.gz: e1a8ff0695efb185bf592950fe4bfa4257a70128c1749c16c41dd78653cccbce
5
5
  SHA512:
6
- metadata.gz: c01be6db48044ac64ba9e551d373c3e3c95eb8d509f1841b973d474c22418da742747bf8536cbbc51c0e5a9501bd0a6d7bb0a0bc17befab45fe179fa219a5934
7
- data.tar.gz: 535aa5e228fe6a8407a104228003f88e654a4fe3e998154b9ad0256de11cbaef072c8f26e82fc76653aa08ec07859f5fa5d10a098cae789568800c7850685685
6
+ metadata.gz: 63901ce27bc846a0d6b323d01b284a26a10f61fd5281ce881d7dc831cdeb70dc47f7f325c23821d69dd5a0328771f4b00000dc2860bd2a0645d6c9b93eb7e468
7
+ data.tar.gz: e46b4ed1feabc3563980aaaa98f0003fbe22fdf0f127ab4a353d704aaf489b9843ec00598013c9e0908b4df5db8cbf61c4d54a0cd3fca3814be523a9e2964b27
data/lib/searchractor.rb CHANGED
@@ -21,7 +21,7 @@ module Searchractor
21
21
 
22
22
  # Internal: Searchractor's instance methods
23
23
  module InstanceMethods
24
- # Public: Search for a given element in an initialized list of sorted elements.
24
+ # Public: Use binary search to look for an element in an initialized list of sorted elements.
25
25
  #
26
26
  # Examples
27
27
  #
@@ -49,5 +49,27 @@ module Searchractor
49
49
  end
50
50
  end
51
51
  end
52
+
53
+ # Public: Use linear search to look for an element in an initialized list of elements.
54
+ #
55
+ # Examples:
56
+ #
57
+ # searchable = SearchractorClass.new([1, 4, 3, 8, 6])
58
+ #
59
+ # searchable.l_search(3) => 2
60
+ #
61
+ # searchable.l_search(10) => nil
62
+ #
63
+ # Returns either the index of the searched element or nil if the element is not found
64
+ # in the list
65
+ def l_search(element)
66
+ i = 0
67
+
68
+ while i <= list.length - 1
69
+ i += 1
70
+
71
+ return i if element == list[i]
72
+ end
73
+ end
52
74
  end
53
75
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: searchractor
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henrique Caltram
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-03-11 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2024-03-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  description:
14
28
  email:
15
29
  executables: []
@@ -18,7 +32,8 @@ extra_rdoc_files: []
18
32
  files:
19
33
  - lib/searchractor.rb
20
34
  homepage:
21
- licenses: []
35
+ licenses:
36
+ - MIT
22
37
  metadata: {}
23
38
  post_install_message:
24
39
  rdoc_options: []
@@ -35,9 +50,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
35
50
  - !ruby/object:Gem::Version
36
51
  version: '0'
37
52
  requirements: []
38
- rubygems_version: 3.4.10
53
+ rubygems_version: 3.5.3
39
54
  signing_key:
40
55
  specification_version: 4
41
- summary: A module dedicated to search algorithms studies in Ruby base on interactor's
56
+ summary: A module dedicated to search algorithms studies in Ruby based on interactor's
42
57
  architecture
43
58
  test_files: []