種類
ライブラリ
- English (36)
- ビルトイン (4024)
- abbrev (12)
- benchmark (24)
- bigdecimal (12)
-
cgi
/ core (48) - coverage (7)
- csv (408)
- date (4)
- dbm (24)
- delegate (12)
- erb (12)
- expect (24)
- fileutils (144)
- getoptlong (24)
-
irb
/ inspector (12) - json (132)
- logger (12)
- matrix (132)
-
minitest
/ unit (7) - mkmf (48)
-
net
/ imap (60) - objspace (12)
- observer (24)
- open3 (108)
- openssl (72)
- optparse (192)
- pathname (12)
- pstore (12)
- psych (43)
- rake (348)
-
rake
/ rdoctask (24) -
rake
/ testtask (24) -
rdoc
/ context (12) -
rdoc
/ text (12) - readline (36)
-
rexml
/ document (72) -
rexml
/ parsers / pullparser (24) -
rexml
/ parsers / ultralightparser (12) -
rinda
/ rinda (36) -
rinda
/ tuplespace (48) - rubygems (36)
-
rubygems
/ command (72) -
rubygems
/ command _ manager (24) -
rubygems
/ commands / build _ command (12) -
rubygems
/ commands / dependency _ command (12) -
rubygems
/ commands / update _ command (12) -
rubygems
/ commands / which _ command (24) -
rubygems
/ config _ file (12) -
rubygems
/ dependency (12) -
rubygems
/ dependency _ installer (72) -
rubygems
/ dependency _ list (24) -
rubygems
/ doc _ manager (12) -
rubygems
/ ext / configure _ builder (12) -
rubygems
/ ext / ext _ conf _ builder (12) -
rubygems
/ ext / rake _ builder (12) -
rubygems
/ format (12) -
rubygems
/ indexer (24) -
rubygems
/ old _ format (12) -
rubygems
/ package / tar _ header (12) -
rubygems
/ platform (12) -
rubygems
/ requirement (24) -
rubygems
/ security (24) -
rubygems
/ source _ index (24) -
rubygems
/ source _ info _ cache (24) -
rubygems
/ spec _ fetcher (48) -
rubygems
/ specification (168) -
rubygems
/ user _ interaction (24) -
rubygems
/ version (24) - scanf (36)
- set (27)
- shell (36)
-
shell
/ command-processor (6) -
shell
/ filter (6) -
shell
/ process-controller (18) - shellwords (36)
- socket (204)
- thwait (6)
- tsort (48)
-
webrick
/ config (12) -
webrick
/ httprequest (24) -
webrick
/ https (12) -
webrick
/ httpserver (12) -
webrick
/ httputils (36) -
win32
/ registry (12) - win32ole (84)
- zlib (24)
クラス
-
ARGF
. class (84) - Array (2250)
- BasicSocket (12)
-
Benchmark
:: Tms (12) - BigDecimal (12)
-
CGI
:: Cookie (12) - CSV (180)
-
CSV
:: Row (48) -
CSV
:: Table (144) - Complex (12)
- Coverage (7)
- DBM (24)
- Data (3)
- Date (2)
- DateTime (2)
- ERB (12)
-
Encoding
:: Converter (36) - Enumerator (24)
-
Gem
:: Command (72) -
Gem
:: CommandManager (24) -
Gem
:: Commands :: BuildCommand (12) -
Gem
:: Commands :: DependencyCommand (12) -
Gem
:: Commands :: UpdateCommand (12) -
Gem
:: Commands :: WhichCommand (24) -
Gem
:: ConfigFile (12) -
Gem
:: Dependency (12) -
Gem
:: DependencyInstaller (72) -
Gem
:: DependencyList (24) -
Gem
:: DocManager (12) -
Gem
:: Ext :: ConfigureBuilder (12) -
Gem
:: Ext :: ExtConfBuilder (12) -
Gem
:: Ext :: RakeBuilder (12) -
Gem
:: Format (12) -
Gem
:: Indexer (24) -
Gem
:: OldFormat (12) -
Gem
:: Package :: TarHeader (12) -
Gem
:: Platform (12) -
Gem
:: Requirement (24) -
Gem
:: Security :: Policy (12) -
Gem
:: Security :: Signer (12) -
Gem
:: SourceIndex (24) -
Gem
:: SourceInfoCache (24) -
Gem
:: SpecFetcher (48) -
Gem
:: Specification (168) -
Gem
:: StreamUI (12) -
Gem
:: Version (24) - GetoptLong (24)
- Hash (124)
- IO (60)
- IPSocket (36)
-
IRB
:: Inspector (12) -
JSON
:: Parser (12) -
JSON
:: State (60) - Logger (12)
- MatchData (62)
- Matrix (60)
- Method (44)
-
MiniTest
:: Unit (2) -
MiniTest
:: Unit :: TestCase (2) - Module (192)
-
Net
:: IMAP (12) -
Net
:: IMAP :: BodyTypeBasic (12) -
Net
:: IMAP :: BodyTypeMessage (12) -
Net
:: IMAP :: BodyTypeMultipart (12) -
Net
:: IMAP :: BodyTypeText (12) - NilClass (12)
- Object (120)
-
OpenSSL
:: BN (12) -
OpenSSL
:: X509 :: ExtensionFactory (36) - OptionParser (144)
-
OptionParser
:: ParseError (48) - PStore (12)
- Pathname (12)
-
RDoc
:: Context (12) -
REXML
:: Element (12) -
REXML
:: Entity (24) -
REXML
:: Parent (36) -
REXML
:: Parsers :: PullEvent (24) -
REXML
:: Parsers :: UltraLightParser (12) -
Rake
:: Application (24) -
Rake
:: FileList (156) -
Rake
:: NameSpace (12) -
Rake
:: RDocTask (24) -
Rake
:: Task (60) -
Rake
:: TaskArguments (12) -
Rake
:: TestTask (24) - Random (60)
- Range (38)
- Rational (24)
- Regexp (12)
-
Rinda
:: TupleEntry (12) -
Rinda
:: TupleSpace (36) -
Rinda
:: TupleSpaceProxy (36) -
RubyVM
:: AbstractSyntaxTree :: Node (7) -
RubyVM
:: InstructionSequence (12) - Set (36)
- Shell (36)
-
Shell
:: CommandProcessor (6) -
Shell
:: Filter (6) -
Shell
:: ProcessController (18) - Socket (120)
-
Socket
:: Option (12) - String (45)
- Struct (16)
- TCPSocket (12)
- ThreadsWait (6)
- Time (14)
- UDPSocket (12)
- UnboundMethod (24)
- Vector (72)
-
WEBrick
:: HTTPRequest (36) -
WEBrick
:: HTTPServer :: MountTable (12) -
WEBrick
:: HTTPUtils :: FormData (24) - WIN32OLE (12)
-
WIN32OLE
_ VARIANT (60) -
Win32
:: Registry (12) -
Zlib
:: GzipReader (12)
モジュール
- Benchmark (12)
-
CGI
:: QueryExtension (24) -
CGI
:: QueryExtension :: Value (24) - Enumerable (651)
- FileUtils (156)
-
GC
:: Profiler (12) - Gem (36)
-
Gem
:: UserInteraction (12) - JSON (24)
-
JSON
:: Generator :: GeneratorMethods :: Array (12) - Kernel (132)
- MiniTest (1)
-
MiniTest
:: Assertions (2) - ObjectSpace (36)
- Observable (24)
- Open3 (108)
-
OpenSSL
:: SSL :: SocketForwarder (24) - Psych (43)
-
RDoc
:: Text (12) -
Rake
:: TaskManager (48) - Shellwords (24)
- TSort (48)
-
WEBrick
:: Config (12) -
WEBrick
:: HTTPUtils (12) -
WIN32OLE
:: VARIANT (12) - Warning (1)
- Zlib (12)
オブジェクト
- ENV (24)
-
Readline
:: HISTORY (24) - main (40)
キーワード
-
$ INPUT _ RECORD _ SEPARATOR (12) -
$ OUTPUT _ FIELD _ SEPARATOR (12) -
$ RS (12) - & (12)
- * (36)
- + (12)
- - (12)
-
1
. 6 . 8から1 . 8 . 0への変更点(まとめ) (12) - << (24)
- <=> (12)
- == (36)
- === (8)
-
ARGUMENT
_ FLAGS (12) - ARGV (12)
-
ARRAY
_ METHODS (12) - ArgumentError (12)
- CSV (12)
-
DEFAULT
_ IGNORE _ PATTERNS (12) -
DEFAULT
_ RAKEFILES (12) -
DELEGATING
_ METHODS (12) - DIRECTORIES (12)
- DelegateClass (12)
- DigestAuth (12)
- Enumerable (12)
- Enumerator (12)
- FIELDS (12)
- FileList (12)
- HISTORY (12)
- Hash (12)
- METHODS (12)
-
MUST
_ DEFINE (12) -
MUST
_ NOT _ DEFINE (12) - Marshal フォーマット (12)
-
NEWS for Ruby 2
. 0 . 0 (12) -
NEWS for Ruby 2
. 1 . 0 (12) -
NEWS for Ruby 2
. 2 . 0 (11) -
NEWS for Ruby 2
. 4 . 0 (9) -
NEWS for Ruby 2
. 5 . 0 (8) -
NEWS for Ruby 2
. 7 . 0 (6) -
NEWS for Ruby 3
. 0 . 0 (5) -
NEWS for Ruby 3
. 1 . 0 (4) - ORDERINGS (12)
- RARRAY (12)
- Rubyで使われる記号の意味(正規表現の複雑な記号は除く) (12)
- Ruby用語集 (12)
-
SEV
_ LABEL (12) -
SPECIAL
_ RETURN (12) - TYPES (12)
- Table (12)
-
VT
_ ARRAY (12) -
WIN
_ PATTERNS (12) - [] (216)
- []= (96)
-
_ invoke (12) - abbrev (12)
- accept (12)
-
accept
_ nonblock (12) - actions (12)
-
active
_ jobs (6) -
add
_ attributes (12) -
add
_ bindir (12) -
add
_ extra _ args (12) -
add
_ observer (12) -
add
_ to (12) - addr (36)
- all? (42)
- any? (62)
- append (8)
-
arg
_ names (12) - args (24)
- argv (12)
- array (12)
-
array
_ attribute (12) -
array
_ attributes (12) -
array
_ nl (12) -
array
_ nl= (12) -
assert
_ send (1) - assoc (36)
- at (12)
-
attribute
_ defaults (12) -
attribute
_ names (12) - bmbm (12)
- bsearch (48)
-
bsearch
_ index (20) - build (36)
-
build
_ args (12) - call (24)
-
capture
_ io (1) - categories (1)
-
cert
_ chain (24) - children (7)
- chmod (12)
-
chmod
_ R (12) -
choose
_ from _ list (24) - chown (12)
-
chown
_ R (12) - cipher (12)
- class (12)
- clear (12)
- clone (12)
- coerce (48)
- collect (48)
- collect! (24)
- collect2 (24)
-
collect
_ concat (24) -
collect
_ method (12) -
column
_ vector (12) - combination (24)
-
command
_ names (12) - commands (12)
- compact (25)
- compact! (21)
-
compact
_ specs (12) - concat (33)
-
configured
_ args (12) - converters (12)
- convpath (12)
- count (72)
-
crc
_ table (12) -
create
_ ext _ from _ array (12) -
create
_ extension (24) -
current
_ scope (12) - cycle (24)
-
deconstruct
_ keys (17) -
default
_ system _ path (6) -
default
_ system _ path= (6) -
define
_ finalizer (24) - delete (24)
-
delete
_ at (12) -
delete
_ if (24) -
delete
_ observers (12) -
depend
_ rules (12) - dependencies (12)
-
dependent
_ gems (12) -
development
_ dependencies (12) - diagonal (12)
- difference (7)
- dig (30)
- drop (24)
-
drop
_ while (48) - dump (24)
- dup (12)
- each (24)
- each2 (24)
-
each
_ index (24) - empty? (24)
- entries (7)
-
enum
_ for (24) - eql? (24)
- expect (24)
- extension (48)
-
extra
_ args (12) - fcntl (12)
- fetch (48)
-
fiddle
/ import (12) - fields (12)
-
file
_ entries (24) - fill (72)
- filter (14)
- filter! (14)
-
filter
_ backtrace (13) -
find
_ command _ possibilities (12) -
find
_ gems _ with _ sources (12) -
find
_ index (36) -
find
_ matching (12) -
find
_ paths (12) -
find
_ reverse _ dependencies (12) -
find
_ spec _ by _ name _ and _ version (12) -
find
_ type (24) - first (48)
-
flat
_ map (24) - flatten (36)
- flatten! (24)
- freeze (12)
-
gather
_ dependencies (12) -
gem
_ file _ list (12) -
gem
_ paths (12) -
gems
_ to _ install (12) - generate (12)
-
generate
_ line (12) -
get
_ all _ gem _ names (12) - getaddrinfo (12)
- gethostbyaddr (12)
- gethostbyname (24)
- getnameinfo (12)
- gets (12)
- grep (24)
- hash (12)
-
header
_ converters (12) - headers (36)
- import (12)
-
in
_ namespace (12) - include? (12)
- index (36)
- insert (12)
- inspect (12)
- install (12)
-
install
_ rb (12) -
installed
_ gems (12) - intersect? (4)
- intersection (6)
- ioctl (12)
-
is
_ a? (12) - jobs (12)
- join (24)
-
keep
_ if (24) -
keys
_ with _ inspector (12) -
kind
_ of? (12) - last (24)
-
latest
_ specs (12) -
legacy
_ repos (12) - length (24)
- libs (12)
-
line
_ stub (7) - list (36)
-
load
_ gemspecs (12) - makedirs (12)
- map (48)
- map! (24)
- map2 (12)
-
mark
_ locations _ array (12) -
marshal
_ dump (48) -
marshal
_ load (24) - max (84)
-
max
_ by (48) - min (84)
-
min
_ by (48) - minmax (24)
- mkdir (18)
-
mkdir
_ p (12) - mkpath (12)
-
module
_ function (24) - names (12)
- new (132)
-
next
_ values (12) - none? (42)
- on (144)
- one? (42)
-
option
_ list (12) - outdated (12)
- p (12)
- pack (21)
- pack テンプレート文字列 (12)
- pair (12)
- params (12)
- parse (60)
-
parse
_ line (12) - path (12)
-
pathmap
_ explode (12) -
peek
_ values (12) - peeraddr (36)
- permutation (24)
- pipeline (12)
-
pipeline
_ r (24) -
pipeline
_ rw (24) -
pipeline
_ start (24) -
pipeline
_ w (24) - pop (24)
- prepend (8)
- prerequisites (12)
-
primitive
_ errinfo (12) - private (68)
-
private
_ class _ method (24) - product (24)
- protected (36)
- public (56)
-
public
_ class _ method (24) - push (12)
- rand (36)
- rassoc (36)
-
rb
_ Array (12) -
rb
_ ary _ new (12) -
rb
_ ary _ new2 (12) -
rb
_ ary _ new3 (12) -
rb
_ ary _ to _ s (12) -
rb
_ check _ convert _ type (12) -
rb
_ f _ array (12) -
rdoc
/ parser / c (12) -
reachable
_ objects _ from (12) - read (48)
-
read
_ all (24) - readline (12)
- readlines (72)
- recover (12)
- recvfrom (12)
-
recvfrom
_ nonblock (12) - reject (48)
- reject! (24)
-
remove
_ by _ name (12) -
repeated
_ combination (24) -
repeated
_ permutation (24) - replace (12)
- report (1)
-
required
_ attributes (12) - requirements (12)
-
resolve
_ args (12) -
response
_ handlers (12) - result (12)
- reverse (12)
- reverse! (12)
-
reverse
_ each (24) - rindex (36)
- roots (12)
- rotate (12)
- rotate! (12)
- row (12)
-
row
_ vector (12) -
ruby 1
. 6 feature (12) -
ruby 1
. 8 . 2 feature (12) -
ruby 1
. 8 . 4 feature (12) -
ruby 1
. 9 feature (12) -
ruby
_ opts (12) -
run
_ test _ suites (1) -
runtime
_ dependencies (12) -
safe
_ load (19) - sample (48)
- scan (12)
- scanf (36)
-
search
_ convpath (12) -
search
_ with _ source (24) - select (36)
- select! (24)
- sendmsg (12)
-
set
_ backtrace (12) -
set
_ eoutvar (12) - shelljoin (24)
- shift (48)
- shuffle (24)
- shuffle! (24)
- size (24)
- slice (36)
- slice! (36)
- socketpair (12)
- sort (24)
- sort! (24)
-
sort
_ by (24) -
sort
_ by! (24) - sources (12)
-
spec
_ predecessors (12) -
specific
_ extra _ args (12) - split (12)
-
split
_ all (12) -
split
_ header _ value (12) -
strongly
_ connected _ components (24) - sum (42)
- sysaccept (12)
-
system
_ path (6) -
system
_ path= (6) - table (24)
- take (48)
-
take
_ while (48) - tap (12)
- tasks (36)
-
test
_ methods (1) -
test
_ suites (1) - threads (6)
-
to
_ a (223) -
to
_ ary (60) -
to
_ csv (12) -
to
_ enum (24) -
to
_ h (31) -
to
_ hash (12) -
to
_ json (12) -
to
_ s (12) -
top
_ level _ tasks (12) - transpose (12)
-
try
_ convert (12) - tsort (24)
- union (19)
- uniq (48)
- uniq! (24)
- unpack (24)
- unpack1 (9)
-
unpack
_ sockaddr _ in (12) - unparse (12)
- unshift (12)
- value (24)
-
values
_ at (60) - vartype (12)
-
verify
_ gem (12) -
waiting
_ jobs (6) -
which
_ to _ update (12) - yaml (12)
- zip (24)
- | (12)
- このマニュアルのヘルプ (12)
- クラス/メソッドの定義 (12)
- パターンマッチ (12)
- メソッド呼び出し(super・ブロック付き・yield) (12)
- リテラル (12)
- 制御構造 (12)
検索結果
先頭5件
-
Array (44000.0)
-
配列クラスです。 配列は任意の Ruby オブジェクトを要素として持つことができます。
配列クラスです。
配列は任意の Ruby オブジェクトを要素として持つことができます。
一般的には配列は配列式を使って
//emlist[例][ruby]{
[1, 2, 3]
//}
のように生成します。 -
Array
# repeated _ combination(n) -> Enumerator (30390.0) -
サイズ n の重複組み合わせをすべて生成し、それを引数としてブロックを実行 します。
...生成する Enumerator オブジェクトを返します。
@param n 生成される配列のサイズを整数で指定します。
整数以外のオブジェクトを指定した場合は to_int メソッドによる暗
黙の型変換を試みます。
@raise TypeError 引......{
a = [1, 2, 3]
a.repeated_combination(1).to_a #=> [[1], [2], [3]]
a.repeated_combination(2).to_a #=> [[1,1],[1,2],[1,3],[2,2],[2,3],[3,3]]
a.repeated_combination(3).to_a #=> [[1,1,1],[1,1,2],[1,1,3],[1,2,2],[1,2,3],
# [1,3,3],[2,2,2],[2,2,3],[2,3,3],[3,3,3]]
a.......して self を返します。
//emlist[例][ruby]{
a = [1, 2, 3]
result = []
a.repeated_combination(3) {|e| result << e} # => [1,2,3]
result #=> [[1,1,1],[1,1,2],[1,1,3],[1,2,2],[1,2,3],
# [1,3,3],[2,2,2],[2,2,3],[2,3,3],[3,3,3]]
//}
@see Array#repeated_permutation, Array#combination... -
Array
# repeated _ permutation(n) -> Enumerator (30378.0) -
サイズ n の重複順列をすべて生成し,それを引数としてブロックを実行します。
...生成する Enumerator オブジェクトを返します。
@param n 生成する配列のサイズを整数で指定します。
整数以外のオブジェクトを指定した場合は to_int メソッドによる暗
黙の型変換を試みます。
@raise TypeError 引数......uby]{
a = [1, 2]
a.repeated_permutation(1).to_a #=> [[1], [2]]
a.repeated_permutation(2).to_a #=> [[1,1],[1,2],[2,1],[2,2]]
a.repeated_permutation(3).to_a #=> [[1,1,1],[1,1,2],[1,2,1],[1,2,2],
# [2,1,1],[2,1,2],[2,2,1],[2,2,2]]
a.repeated_permutation(0).to_a #=......ロックを実
行して self を返します。
//emlist[例][ruby]{
a = [1, 2]
result = []
a.repeated_permutation(3) {|e| result << e} # => [1,2]
result #=> [[1,1,1],[1,1,2],[1,2,1],[1,2,2],
# [2,1,1],[2,1,2],[2,2,1],[2,2,2]]
//}
@see Array#repeated_combination, Array#permutation... -
Array
# repeated _ combination(n) { |c| . . . } -> self (30290.0) -
サイズ n の重複組み合わせをすべて生成し、それを引数としてブロックを実行 します。
...生成する Enumerator オブジェクトを返します。
@param n 生成される配列のサイズを整数で指定します。
整数以外のオブジェクトを指定した場合は to_int メソッドによる暗
黙の型変換を試みます。
@raise TypeError 引......{
a = [1, 2, 3]
a.repeated_combination(1).to_a #=> [[1], [2], [3]]
a.repeated_combination(2).to_a #=> [[1,1],[1,2],[1,3],[2,2],[2,3],[3,3]]
a.repeated_combination(3).to_a #=> [[1,1,1],[1,1,2],[1,1,3],[1,2,2],[1,2,3],
# [1,3,3],[2,2,2],[2,2,3],[2,3,3],[3,3,3]]
a.......して self を返します。
//emlist[例][ruby]{
a = [1, 2, 3]
result = []
a.repeated_combination(3) {|e| result << e} # => [1,2,3]
result #=> [[1,1,1],[1,1,2],[1,1,3],[1,2,2],[1,2,3],
# [1,3,3],[2,2,2],[2,2,3],[2,3,3],[3,3,3]]
//}
@see Array#repeated_permutation, Array#combination... -
Array
# repeated _ permutation(n) { |p| . . . } -> self (30278.0) -
サイズ n の重複順列をすべて生成し,それを引数としてブロックを実行します。
...生成する Enumerator オブジェクトを返します。
@param n 生成する配列のサイズを整数で指定します。
整数以外のオブジェクトを指定した場合は to_int メソッドによる暗
黙の型変換を試みます。
@raise TypeError 引数......uby]{
a = [1, 2]
a.repeated_permutation(1).to_a #=> [[1], [2]]
a.repeated_permutation(2).to_a #=> [[1,1],[1,2],[2,1],[2,2]]
a.repeated_permutation(3).to_a #=> [[1,1,1],[1,1,2],[1,2,1],[1,2,2],
# [2,1,1],[2,1,2],[2,2,1],[2,2,2]]
a.repeated_permutation(0).to_a #=......ロックを実
行して self を返します。
//emlist[例][ruby]{
a = [1, 2]
result = []
a.repeated_permutation(3) {|e| result << e} # => [1,2]
result #=> [[1,1,1],[1,1,2],[1,2,1],[1,2,2],
# [2,1,1],[2,1,2],[2,2,1],[2,2,2]]
//}
@see Array#repeated_combination, Array#permutation... -
Array
# to _ ary -> self (30130.0) -
self をそのまま返します。
...をそのまま返します。
//emlist[例][ruby]{
class SubArray < Array; end
ary1 = Array([1, 2, 3, 4])
ary2 = SubArray([1, 2, 3, 4])
ary1.to_ary # => [1, 2, 3, 4]
ary1.to_ary.class # => Array
ary2.to_ary # => [1, 2, 3, 4]
ary2.to_ary.class # => SubArray
//}
@see Array#to_a... -
Array
# bsearch _ index -> Enumerator (30124.0) -
ブロックの評価結果で範囲内の各要素の判定を行い、条件を満たす値の位置を 二分探索(計算量は O(log n))で検索します。要素が見つからない場合は nil を返します。self はあらかじめソートしておく必要があります。
...ソッドはArray#bsearchと同様に、ブロックを評価した結果により2
つのモードで動作します。Array#bsearch との違いは見つかった要素自
身を返すか位置を返すかのみです。各モードのより詳細な違いについては
Array#bsearch を参照し......ind-minimum モード][ruby]{
ary = [0, 4, 7, 10, 12]
ary.bsearch_index { |x| x >= 4 } # => 1
ary.bsearch_index { |x| x >= 6 } # => 2
ary.bsearch_index { |x| x >= -1 } # => 0
ary.bsearch_index { |x| x >= 100 } # => nil
//}
//emlist[例: find-any モード][ruby]{
ary = [0, 4, 7, 10, 12]
# 4 <=......v < 8 になる要素の位置を検索
ary.bsearch_index { |x| 1 - x / 4 } # => 2
# 8 <= v < 10 になる要素の位置を検索
ary.bsearch_index { |x| 4 - x / 2 } # => nil
//}
@see Array#bsearch... -
Array
# bsearch _ index { |x| . . . } -> Integer | nil (30124.0) -
ブロックの評価結果で範囲内の各要素の判定を行い、条件を満たす値の位置を 二分探索(計算量は O(log n))で検索します。要素が見つからない場合は nil を返します。self はあらかじめソートしておく必要があります。
...ソッドはArray#bsearchと同様に、ブロックを評価した結果により2
つのモードで動作します。Array#bsearch との違いは見つかった要素自
身を返すか位置を返すかのみです。各モードのより詳細な違いについては
Array#bsearch を参照し......ind-minimum モード][ruby]{
ary = [0, 4, 7, 10, 12]
ary.bsearch_index { |x| x >= 4 } # => 1
ary.bsearch_index { |x| x >= 6 } # => 2
ary.bsearch_index { |x| x >= -1 } # => 0
ary.bsearch_index { |x| x >= 100 } # => nil
//}
//emlist[例: find-any モード][ruby]{
ary = [0, 4, 7, 10, 12]
# 4 <=......v < 8 になる要素の位置を検索
ary.bsearch_index { |x| 1 - x / 4 } # => 2
# 8 <= v < 10 になる要素の位置を検索
ary.bsearch_index { |x| 4 - x / 2 } # => nil
//}
@see Array#bsearch... -
Array
# bsearch -> Enumerator (30106.0) -
ブロックの評価結果で範囲内の各要素の判定を行い、条件を満たす値を二分探 索(計算量は O(log n))で検索します。要素が見つからない場合は nil を返し ます。self はあらかじめソートしておく必要があります。
...メソッドはブロックを評価した結果により以下のいずれかのモードで動作し
ます。
* find-minimum モード
* find-any モード
find-minimum モード(特に理由がない限りはこのモードを使う方がいいでしょ
う)では、条件判定の結果を......の場合: false を返す
ブロックの評価結果が true になる最初の要素を返すか、nil を返します。
//emlist[例][ruby]{
ary = [0, 4, 7, 10, 12]
ary.bsearch {|x| x >= 4 } # => 4
ary.bsearch {|x| x >= 6 } # => 7
ary.bsearch {|x| x >= -1 } # => 0
ary.bsearch {|x| x >= 1......Enumerator のインスタンスを返します。
@raise TypeError ブロックの評価結果が true、false、nil、数値以外であっ
た場合に発生します。
@see Array#bsearch_index, Range#bsearch, https://magazine.rubyist.net/articles/0041/0041-200Special-note.ht...