This repository was archived by the owner on Mar 19, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcollections_9.html
More file actions
57 lines (57 loc) · 3.31 KB
/
collections_9.html
File metadata and controls
57 lines (57 loc) · 3.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html dir="ltr" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
<meta name="generator" content=
"HTML Tidy for Mac OS X (vers 25 March 2009), see www.w3.org" />
<title>Scala 2.8 コレクション API -- ビット集合</title>
<link rel="stylesheet" type="text/css" href="guide.css" />
</head>
<body dir="ltr">
<table width="100%" cellpadding="0" cellspacing="2">
<tr>
<td bgcolor="#99CCFF"><img alt="" src="blank.png" /></td>
<td bgcolor="#99CCFF"><a href="collections_7.html"><img border="0"
alt="集合" src="up.png" /></a></td>
<td bgcolor="#99CCFF"><a href="collections_8.html"><img border="0"
alt="整列済み集合" src="previous.png" /></a></td>
<td align="center" bgcolor="#99CCFF" width="100%"><b>ビット集合</b></td>
<td bgcolor="#99CCFF" align="center" class="tocref"><a href=
"collections_49.html">目次</a></td>
</tr>
</table>
<blockquote style=
"border-left: 1px solid gray; font-family: Century, Times, 'Times New Roman', 'MS Gothic', serif; padding-left: 1em;">
最新版は <a href="http://docs.scala-lang.org/ja/overviews/collections/sets.html">Scala Documentation</a> に移行しました。
</blockquote>
<h2>ビット集合</h2>
<p>ビット集合 (<a href=
"http://www.scala-lang.org/api/current/scala/collection/BitSet.html"><tt>BitSet</tt></a>) は非負整数の要素の集合で、何ワードかのパックされたビットにより実装されている。<a href=
"http://www.scala-lang.org/api/current/scala/collection/BitSet.html"><tt>BitSet</tt></a>
クラスは、内部で <tt>Long</tt> の配列を用いている。最初の <tt>Long</tt> は第0 〜 63
の要素を受け持ち、次のは第64 〜 127 の要素という具合だ<sup><a href=
"collections_50.html#id1">1</a></sup>。全ての <tt>Long</tt> の、それぞれの
64ビットは、対応する要素が集合に含まれる場合は 1 にセットされ、含まれない場合は 0
になる。このため、ビット集合のサイズは格納されている整数の最大値に依存する。<tt>N</tt>
がその最大の整数値の場合、集合のサイズは <tt>N/64</tt> <tt>Long</tt> ワード、または
<tt>N/8</tt> バイト、にステータス情報のためのバイトを追加したものだ。</p>
<p>このため、たくさんの小さい要素を含む場合、ビット集合は他の集合に比べてコンパクトである。ビット集合のもう一つの利点は
<tt>contains</tt> を使った所属判定や、<tt>+=</tt> や <tt>-=</tt>
を使った要素の追加や削除が非常に効率的であることだ。</p>
<p>続いては、<a href="collections_10.html">マップ</a></p>
<hr />
<table width="100%" cellpadding="0" cellspacing="2">
<tr>
<td bgcolor="#99CCFF"><img alt="" src="blank.png" /></td>
<td bgcolor="#99CCFF"><a href="collections_7.html"><img border="0"
alt="集合" src="up.png" /></a></td>
<td bgcolor="#99CCFF"><a href="collections_8.html"><img border="0"
alt="整列済み集合" src="previous.png" /></a></td>
<td align="center" bgcolor="#99CCFF" width="100%"><b>ビット集合</b></td>
<td bgcolor="#99CCFF" align="center" class="tocref"><a href=
"collections_49.html">目次</a></td>
</tr>
</table>
</body>
</html>