fast_filter 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: 35b0ac4af3d4e37606fd35dc4a7a5003f85c03c9
4
- data.tar.gz: f39cc49a2bcdfc8fa11ee53bee81bc9401bbf8e0
3
+ metadata.gz: 5b7c59fd7fa385ec7291e61361f69873c7472fed
4
+ data.tar.gz: 789194ec48d08a7a37492486e7866308e1f39b85
5
5
  SHA512:
6
- metadata.gz: 3d3e077f82d061514d14c040dc3b3d68c734a217a12049c8622710c5d2bedf5854770be8395b8cf733922f338459a557507c61911bd7f968aed8efd42ae1c23b
7
- data.tar.gz: 392efb557560a0e514a4b50e222a5e6af1fcd9e839c02e3f54343f4611e23fc395bb11a76d48a92180d6d744b91728319dbfeb477b4ef615905341c7b6700e10
6
+ metadata.gz: 3463ecc5ce24290345f02c508582691551adae0426439fe5c721ad2b0ec8e77e3b5d4e1a38bf01598d95e97732b82fc649436c47a4faf802f68906f5c382ca93
7
+ data.tar.gz: 45f403782a6bc5e8428c92c732429a69d895e622bca6234e8021b087eab1926ed47c7f0326fa91da8a5a63e56fe1c0e9b4b8166035f27065eb72b9762cc0cbd0
data/CHANGELOG.md ADDED
@@ -0,0 +1,15 @@
1
+ # Change Log
2
+ All notable changes to this project will be documented in this file.
3
+
4
+ The format is based on [Keep a Changelog](http://keepachangelog.com/)
5
+ and this project adheres to [Semantic Versioning](http://semver.org/).
6
+
7
+ ## [Unreleased]
8
+
9
+ ## [0.0.2] - 2017-05-05
10
+ ### Fixed
11
+ - Ruby versions before 2.3.0 now supported
12
+ - Compiling correctly on Linux
13
+
14
+ [Unreleased]: https://github.com/TandaHQ/fast_filter/compare/v0.0.2...HEAD
15
+ [0.0.2]: https://github.com/TandaHQ/fast_filter/compare/v0.0.1...v0.0.2
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2016 Dave Allie
3
+ Copyright (c) 2017 Tanda
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/Rakefile CHANGED
@@ -7,4 +7,4 @@ Rake::ExtensionTask.new 'fast_filter' do |ext|
7
7
  end
8
8
  RSpec::Core::RakeTask.new(:spec)
9
9
 
10
- task default: :spec
10
+ task default: [:compile, :spec]
@@ -10,11 +10,13 @@ static int asc_comp_fn(const void *a, const void *b) {
10
10
  }
11
11
 
12
12
  static int bin_lower_bound(long **a, int lo, int hi, long x) {
13
+ int mid;
14
+
13
15
  if (lo > hi) {
14
16
  return lo;
15
17
  }
16
18
 
17
- int mid = lo + (hi - lo) / 2;
19
+ mid = lo + (hi - lo) / 2;
18
20
  if (a[mid][0] == x) {
19
21
  return bin_lower_bound(a, lo, mid - 1, x);
20
22
  } else if (a[mid][0] > x) {
@@ -25,11 +27,13 @@ static int bin_lower_bound(long **a, int lo, int hi, long x) {
25
27
  }
26
28
 
27
29
  static int bin_upper_bound(long **a, int lo, int hi, long x) {
30
+ int mid;
31
+
28
32
  if (lo > hi) {
29
33
  return lo;
30
34
  }
31
35
 
32
- int mid = lo + (hi - lo) / 2;
36
+ mid = lo + (hi - lo) / 2;
33
37
  if (a[mid][0] == x) {
34
38
  return bin_upper_bound(a, mid + 1, hi, x);
35
39
  } else if (a[mid][0] > x) {
@@ -42,9 +46,11 @@ static int bin_upper_bound(long **a, int lo, int hi, long x) {
42
46
  // ============== BUILD AND FREE FUNCTIONS ==============
43
47
 
44
48
  static void build_c_arr(long ***c_arr, VALUE *rb_array, int *len) {
45
- *len = (int) rb_array_len(*rb_array);
49
+ int i;
50
+ *len = (int) RARRAY_LEN(*rb_array);
46
51
  *c_arr = (long **) malloc(*len * sizeof(long *));
47
- for (int i = 0; i < *len; i++) {
52
+
53
+ for (i = 0; i < *len; i++) {
48
54
  (*c_arr)[i] = (long *) malloc(2 * sizeof(long));
49
55
  (*c_arr)[i][0] = FIX2LONG(rb_ary_entry(*rb_array, i));
50
56
  (*c_arr)[i][1] = i;
@@ -54,17 +60,19 @@ static void build_c_arr(long ***c_arr, VALUE *rb_array, int *len) {
54
60
  }
55
61
 
56
62
  static void free_c_arr(long **c_arr, int len) {
57
- for (int i = 0; i < len; i++) {
63
+ int i;
64
+ for (i = 0; i < len; i++) {
58
65
  free(c_arr[i]);
59
66
  }
60
67
  free(c_arr);
61
68
  }
62
69
 
63
70
  static void build_rb_arr(VALUE *r_arr, long **c_arr, int start, int finish, int index_mode) {
64
- *r_arr = rb_ary_new2(finish - start);
71
+ int ci, ri;
65
72
  int c_arr_index = index_mode;
73
+ *r_arr = rb_ary_new2(finish - start);
66
74
 
67
- for (int ci = start, ri = 0; ci < finish; ci++, ri++) {
75
+ for (ci = start, ri = 0; ci < finish; ci++, ri++) {
68
76
  rb_ary_store(*r_arr, ri, LONG2FIX(c_arr[ci][c_arr_index]));
69
77
  }
70
78
  }
@@ -74,41 +82,41 @@ static void build_rb_arr(VALUE *r_arr, long **c_arr, int start, int finish, int
74
82
  // public filter functions
75
83
 
76
84
  static void lt_filter_with_mode(VALUE *input_rb_array, VALUE *max_value, int index_mode, VALUE *output_rb_array) {
77
- int len;
85
+ int len, last;
78
86
  long **c_arr;
79
87
  build_c_arr(&c_arr, input_rb_array, &len);
80
88
 
81
- int last = bin_lower_bound(c_arr, 0, len - 1, FIX2LONG(*max_value));
89
+ last = bin_lower_bound(c_arr, 0, len - 1, FIX2LONG(*max_value));
82
90
  build_rb_arr(output_rb_array, c_arr, 0, last, index_mode);
83
91
  free_c_arr(c_arr, len);
84
92
  }
85
93
 
86
94
  static void lte_filter_with_mode(VALUE *input_rb_array, VALUE *max_value, int index_mode, VALUE *output_rb_array) {
87
- int len;
95
+ int len, last;
88
96
  long **c_arr;
89
97
  build_c_arr(&c_arr, input_rb_array, &len);
90
98
 
91
- int last = bin_upper_bound(c_arr, 0, len - 1, FIX2LONG(*max_value));
99
+ last = bin_upper_bound(c_arr, 0, len - 1, FIX2LONG(*max_value));
92
100
  build_rb_arr(output_rb_array, c_arr, 0, last, index_mode);
93
101
  free_c_arr(c_arr, len);
94
102
  }
95
103
 
96
104
  static void gt_filter_with_mode(VALUE *input_rb_array, VALUE *max_value, int index_mode, VALUE *output_rb_array) {
97
- int len;
105
+ int len, first;
98
106
  long **c_arr;
99
107
  build_c_arr(&c_arr, input_rb_array, &len);
100
108
 
101
- int first = bin_upper_bound(c_arr, 0, len - 1, FIX2LONG(*max_value));
109
+ first = bin_upper_bound(c_arr, 0, len - 1, FIX2LONG(*max_value));
102
110
  build_rb_arr(output_rb_array, c_arr, first, len, index_mode);
103
111
  free_c_arr(c_arr, len);
104
112
  }
105
113
 
106
114
  static void gte_filter_with_mode(VALUE *input_rb_array, VALUE *max_value, int index_mode, VALUE *output_rb_array) {
107
- int len;
115
+ int len, first;
108
116
  long **c_arr;
109
117
  build_c_arr(&c_arr, input_rb_array, &len);
110
118
 
111
- int first = bin_lower_bound(c_arr, 0, len - 1, FIX2LONG(*max_value));
119
+ first = bin_lower_bound(c_arr, 0, len - 1, FIX2LONG(*max_value));
112
120
  build_rb_arr(output_rb_array, c_arr, first, len, index_mode);
113
121
  free_c_arr(c_arr, len);
114
122
  }
Binary file
Binary file
@@ -1,3 +1,3 @@
1
1
  module FastFilter
2
- VERSION = '0.0.1'.freeze
2
+ VERSION = '0.0.2'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fast_filter
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
  - Dave Allie
@@ -74,9 +74,7 @@ extensions:
74
74
  - ext/fast_filter/extconf.rb
75
75
  extra_rdoc_files: []
76
76
  files:
77
- - ".gitignore"
78
- - ".rspec"
79
- - ".travis.yml"
77
+ - CHANGELOG.md
80
78
  - CODE_OF_CONDUCT.md
81
79
  - Gemfile
82
80
  - LICENSE.txt
@@ -86,8 +84,9 @@ files:
86
84
  - bin/setup
87
85
  - ext/fast_filter/extconf.rb
88
86
  - ext/fast_filter/fast_filter.c
89
- - fast_filter.gemspec
90
87
  - lib/fast_filter.rb
88
+ - lib/fast_filter/fast_filter.bundle
89
+ - lib/fast_filter/fast_filter.so
91
90
  - lib/fast_filter/version.rb
92
91
  homepage: https://github.com/TandaHQ/fast_filter
93
92
  licenses:
data/.gitignore DELETED
@@ -1,11 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /Gemfile.lock
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
- /pkg/
8
- /spec/reports/
9
- /tmp/
10
- *.bundle
11
- *.gem
data/.rspec DELETED
@@ -1,2 +0,0 @@
1
- --format documentation
2
- --color
data/.travis.yml DELETED
@@ -1,19 +0,0 @@
1
- sudo: required
2
- language: ruby
3
- matrix:
4
- include:
5
- - rvm: 2.0.0
6
- - rvm: 2.1.10
7
- - rvm: 2.2.6
8
- - rvm: 2.3.3
9
- - rvm: 2.4.1
10
- - rvm: ruby-head
11
- allow_failures:
12
- - rvm: ruby-head
13
- before_install:
14
- - sudo apt-get update -qq
15
- - sudo apt-get install -y build-essential cmake libpopt-dev libbz2-dev libruby ruby-dev
16
- - gem install bundler -v 1.12.5
17
- install:
18
- - bundle install --jobs=3 --retry=3
19
- - bundle exec rake compile
data/fast_filter.gemspec DELETED
@@ -1,27 +0,0 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'fast_filter/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = 'fast_filter'
8
- spec.version = FastFilter::VERSION
9
- spec.authors = ['Dave Allie']
10
- spec.email = ['dave@tanda.co']
11
-
12
- spec.summary = 'Native Ruby extension to filter a list quickly.'
13
- spec.description = 'Native Ruby extension to filter a list quickly.'
14
- spec.homepage = 'https://github.com/TandaHQ/fast_filter'
15
- spec.license = 'MIT'
16
-
17
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
- spec.bindir = 'exe'
19
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
- spec.require_paths = ['lib']
21
- spec.extensions = ['ext/fast_filter/extconf.rb']
22
-
23
- spec.add_development_dependency 'bundler', '~> 1.12'
24
- spec.add_development_dependency 'rake', '~> 10.0'
25
- spec.add_development_dependency 'rake-compiler', '~> 1.0'
26
- spec.add_development_dependency 'rspec', '~> 3.0'
27
- end