bijection 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +6 -0
- data/.rvmrc +1 -0
- data/.yardopts +2 -0
- data/Gemfile +7 -0
- data/Rakefile +1 -0
- data/bijection.gemspec +20 -0
- data/lib/bijection.rb +12 -0
- data/lib/bijection/base.rb +68 -0
- data/lib/bijection/version.rb +3 -0
- data/spec/spec_helper.rb +4 -0
- metadata +55 -0
data/.gitignore
ADDED
data/.rvmrc
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
rvm 1.9.2@bijection
|
data/.yardopts
ADDED
data/Gemfile
ADDED
data/Rakefile
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require 'bundler/gem_tasks'
|
data/bijection.gemspec
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
|
3
|
+
require "bijection/version"
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |s|
|
|
6
|
+
s.name = "bijection"
|
|
7
|
+
s.version = Bijection::VERSION
|
|
8
|
+
s.authors = ["Ryan Berckmans"]
|
|
9
|
+
s.email = ["ryan.berckmans@gmail.com"]
|
|
10
|
+
s.homepage = "https://github.com/ryanberckmans/bijection"
|
|
11
|
+
s.summary = "bijection container in ruby; pre-alpha wip"
|
|
12
|
+
s.description = s.summary
|
|
13
|
+
|
|
14
|
+
s.rubyforge_project = "bijection"
|
|
15
|
+
|
|
16
|
+
s.files = `git ls-files`.split("\n")
|
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
|
19
|
+
s.require_paths = ["lib"]
|
|
20
|
+
end
|
data/lib/bijection.rb
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
module Bijection
|
|
2
|
+
|
|
3
|
+
# @example
|
|
4
|
+
# b = Bijection.new
|
|
5
|
+
# => Bijection::Base
|
|
6
|
+
class Base
|
|
7
|
+
def initialize
|
|
8
|
+
@x = {}
|
|
9
|
+
@y = {}
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
# add (x,y) to the bijection set (X,Y)
|
|
13
|
+
# @param x the object associated with y
|
|
14
|
+
# @param y the object associated with x
|
|
15
|
+
# @note x must be unique in X; y must be unique in Y
|
|
16
|
+
# @return self
|
|
17
|
+
def map( x, y )
|
|
18
|
+
self
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# @return [Enumerator] the domain set X
|
|
22
|
+
def domain
|
|
23
|
+
@x.each_key
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# @return [Enumerator] the range set Y
|
|
27
|
+
def range
|
|
28
|
+
@y.each_key
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# swap domain X and range Y of this
|
|
32
|
+
# @return nil
|
|
33
|
+
def inverse!
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# @param y in domain set Y
|
|
37
|
+
# @return the x associated with y
|
|
38
|
+
def get_x( y )
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# @param x in domain set X
|
|
42
|
+
# @return the y associated with x
|
|
43
|
+
def get_y( x )
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# @return [Enumerator] an enumerator all (x,y)
|
|
47
|
+
def each_pair
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# given x, delete (x,y) and return y
|
|
51
|
+
# @param (see #get_x)
|
|
52
|
+
# @example
|
|
53
|
+
# b = Bijection.new
|
|
54
|
+
# x = 2 ; y = 3
|
|
55
|
+
# b.map x, y
|
|
56
|
+
# y = nil
|
|
57
|
+
# while 1 { y = b.delete_x x ; b.map x, y }
|
|
58
|
+
# @return the y associated with x
|
|
59
|
+
def delete_x( x )
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# given y, delete (x,y) and return x
|
|
63
|
+
# @param (see #get_y)
|
|
64
|
+
# @return x associated with y
|
|
65
|
+
def delete_y( y )
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: bijection
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
prerelease:
|
|
6
|
+
platform: ruby
|
|
7
|
+
authors:
|
|
8
|
+
- Ryan Berckmans
|
|
9
|
+
autorequire:
|
|
10
|
+
bindir: bin
|
|
11
|
+
cert_chain: []
|
|
12
|
+
date: 2011-06-20 00:00:00.000000000Z
|
|
13
|
+
dependencies: []
|
|
14
|
+
description: bijection container in ruby; pre-alpha wip
|
|
15
|
+
email:
|
|
16
|
+
- ryan.berckmans@gmail.com
|
|
17
|
+
executables: []
|
|
18
|
+
extensions: []
|
|
19
|
+
extra_rdoc_files: []
|
|
20
|
+
files:
|
|
21
|
+
- .gitignore
|
|
22
|
+
- .rvmrc
|
|
23
|
+
- .yardopts
|
|
24
|
+
- Gemfile
|
|
25
|
+
- Rakefile
|
|
26
|
+
- bijection.gemspec
|
|
27
|
+
- lib/bijection.rb
|
|
28
|
+
- lib/bijection/base.rb
|
|
29
|
+
- lib/bijection/version.rb
|
|
30
|
+
- spec/spec_helper.rb
|
|
31
|
+
homepage: https://github.com/ryanberckmans/bijection
|
|
32
|
+
licenses: []
|
|
33
|
+
post_install_message:
|
|
34
|
+
rdoc_options: []
|
|
35
|
+
require_paths:
|
|
36
|
+
- lib
|
|
37
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
38
|
+
none: false
|
|
39
|
+
requirements:
|
|
40
|
+
- - ! '>='
|
|
41
|
+
- !ruby/object:Gem::Version
|
|
42
|
+
version: '0'
|
|
43
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
44
|
+
none: false
|
|
45
|
+
requirements:
|
|
46
|
+
- - ! '>='
|
|
47
|
+
- !ruby/object:Gem::Version
|
|
48
|
+
version: '0'
|
|
49
|
+
requirements: []
|
|
50
|
+
rubyforge_project: bijection
|
|
51
|
+
rubygems_version: 1.8.5
|
|
52
|
+
signing_key:
|
|
53
|
+
specification_version: 3
|
|
54
|
+
summary: bijection container in ruby; pre-alpha wip
|
|
55
|
+
test_files: []
|