Scala Tutorialsを読む 24 Sets

http://scalatutorials.com/tour/interactive_tour_of_scala_sets.html

24 Sets 集合

  • Sets are constructed simply using Set(element1, element2, ...)
  • 集合は単純にSet(要素1,要素2,...)を使って構築されます。
  • The Set can contain mixed types, but the final type of the elements will be the lowest common denominator
  • Setは混ぜた型を含む事が出来ますが、最終的な要素の型は共通の小限になります。
  • The default Set is Predef.Set which points to scala.collection.immutable.Set
  • デフォルト集合はPredef.Setにありscala.collection.immutable.Setのリンク貼ってる感じです。
  • As it currently stands, Set implementation up to size of 4 has a specific class Set1, Set2, Set3, Set4, beyond that, it uses an immutable HashSet
  • 現在表したように、Setの実装は4のサイズまでは、特別なクラスSet1,Set2,Set3,Set4を持ち、それ以降はimmutable HashSetを使う。
  • You can't have duplicate values, adding a value that already exists overwrites the value
  • 値はコピー出来ず、値を追加する事は既に存在している値を上書きする
  • Order of iteration is not guaranteed to be consistent
  • イテレーションするオーダーは一貫性を保証するものではない。 See Also opens in new page 新しいページを開いて参照

  • Predef source Predefのソース

  • Predef docs Predefのドキュメント
  • Set's scala docs Scala集合ドキュメント
  • Set's sources 集合のソース