| 1 |
<!DOCTYPE html> |
| 2 |
<!-- |
| 3 |
~ Copyright (c) 2021 Goldman Sachs and others. |
| 4 |
~ All rights reserved. This program and the accompanying materials |
| 5 |
~ are made available under the terms of the Eclipse Public License v1.0 |
| 6 |
~ and Eclipse Distribution License v. 1.0 which accompany this distribution. |
| 7 |
~ The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html |
| 8 |
~ and the Eclipse Distribution License is available at |
| 9 |
~ http://www.eclipse.org/org/documents/edl-v10.php. |
| 10 |
--> |
| 11 |
|
| 12 |
<html lang="cn"> |
| 13 |
|
| 14 |
<head> |
| 15 |
|
| 16 |
<meta charset="utf-8"> |
| 17 |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> |
| 18 |
<meta name="viewport" content="width=device-width, initial-scale=1"> |
| 19 |
<meta name="description" content=""> |
| 20 |
<meta name="author" content=""> |
| 21 |
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico" /> |
| 22 |
|
| 23 |
<title>Eclipse Collections - 满足你所有需求的集合包。 </title> |
| 24 |
|
| 25 |
<!-- Bootstrap Core CSS --> |
| 26 |
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" integrity="sha256-7s5uDGW3AHqw6xtJmNNtr+OBRJUlgkNJEo78P4b0yRw= sha512-nNo+yCHEyn0smMxSswnf/OnX6/KwJuZTlNZBjauKhTK0c+zT+q5JOCx0UFhXQ6rJR9jg6Es8gPuD2uZcYDLqSw==" crossorigin="anonymous"> |
| 27 |
|
| 28 |
<!-- Custom CSS --> |
| 29 |
<link href="../css/landing-page.css" rel="stylesheet"> |
| 30 |
|
| 31 |
<!-- Custom Fonts --> |
| 32 |
<link href="//fonts.googleapis.com/css?family=Roboto+Condensed:300,400,700,300italic,400italic,700italic" rel="stylesheet" type="text/css"> |
| 33 |
|
| 34 |
<!-- Google Code Prettify --> |
| 35 |
<link href="../css/sunburst.css" rel="stylesheet" type="text/css"> |
| 36 |
|
| 37 |
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries --> |
| 38 |
<!-- WARNING: Respond.js doesn't work if you view the page via file:// --> |
| 39 |
<!--[if lt IE 9]> |
| 40 |
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script> |
| 41 |
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script> |
| 42 |
<![endif]--> |
| 43 |
|
| 44 |
</head> |
| 45 |
|
| 46 |
<body> |
| 47 |
|
| 48 |
<!-- Navigation --> |
| 49 |
<nav class="navbar navbar-default navbar-fixed-top topnav" role="navigation"> |
| 50 |
<div class="container topnav"> |
| 51 |
<!-- Brand and toggle get grouped for better mobile display --> |
| 52 |
<div class="navbar-header"> |
| 53 |
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1"> |
| 54 |
<span class="sr-only">Toggle navigation</span> |
| 55 |
<span class="icon-bar"></span> |
| 56 |
<span class="icon-bar"></span> |
| 57 |
<span class="icon-bar"></span> |
| 58 |
</button> |
| 59 |
<img src="../img/eclipse-collections-logo.png" style="width:175px;height:50px;" align="left" alt="Eclipse Collections"> |
| 60 |
</div> |
| 61 |
<!-- Collect the nav links, forms, and other content for toggling --> |
| 62 |
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> |
| 63 |
<ul class="nav navbar-nav navbar-right"> |
| 64 |
<li> |
| 65 |
<a href="#start">入门须知</a> |
| 66 |
</li> |
| 67 |
<li> |
| 68 |
<a href="#concept">概念</a> |
| 69 |
</li> |
| 70 |
<li> |
| 71 |
<a href="#learn">学习</a> |
| 72 |
</li> |
| 73 |
<li> |
| 74 |
<a href="#history">历史</a> |
| 75 |
</li> |
| 76 |
<li> |
| 77 |
<a href="#refGuide">参考指南</a> |
| 78 |
</li> |
| 79 |
<li> |
| 80 |
<a href="#sourceCode">源代码</a> |
| 81 |
</li> |
| 82 |
<li> |
| 83 |
<a href="#contribute">贡献</a> |
| 84 |
</li> |
| 85 |
<li class="dropdown"> |
| 86 |
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" |
| 87 |
aria-expanded="false">Javadoc<span class="caret"></span></a> |
| 88 |
<ul class="dropdown-menu"> |
| 89 |
<li><a href="../javadoc/11.0.0">11.0.0</a></li> |
| 90 |
<li><a href="../javadoc/10.4.0">10.4.0</a></li> |
| 91 |
<li><a href="../javadoc/10.3.0">10.3.0</a></li> |
| 92 |
<li><a href="../javadoc/10.2.0">10.2.0</a></li> |
| 93 |
<li><a href="../javadoc/10.1.0">10.1.0</a></li> |
| 94 |
<li><a href="../javadoc/10.0.0">10.0.0</a></li> |
| 95 |
<li><a href="../javadoc/9.2.0">9.2.0</a></li> |
| 96 |
<li><a href="../javadoc/8.2.0">8.2.0</a></li> |
| 97 |
<li><a href="../javadoc/7.1.0">7.1.0</a></li> |
| 98 |
</ul> |
| 99 |
</li> |
| 100 |
<li class="dropdown"> |
| 101 |
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" |
| 102 |
aria-expanded="false">语言<span class="caret"></span></a> |
| 103 |
<ul class="dropdown-menu"> |
| 104 |
<li><a href="../index.html">English</a></li> |
| 105 |
<li><a href="../de/index.html">Deutsch</a></li> |
| 106 |
<li><a href="../el/index.html">Ελληνικά</a></li> |
| 107 |
<li><a href="../es/index.html">Español</a></li> |
| 108 |
<li><a href="">中文</a></li> |
| 109 |
<li><a href="../fr/index.html">Français</a></li> |
| 110 |
<li><a href="../ja/index.html">日本語</a></li> |
| 111 |
<li><a href="../no-nb/index.html">Norsk (bokmål)</a></li> |
| 112 |
<li><a href="../pt-br/index.html">Português-Brasil</a></li> |
| 113 |
<li><a href="../ru/index.html">Русский</a></li> |
| 114 |
<li><a href="../hi/index.html">हिंदी</a></li> |
| 115 |
</ul> |
| 116 |
</li> |
| 117 |
</ul> |
| 118 |
</div> |
| 119 |
<!-- /.navbar-collapse --> |
| 120 |
</div> |
| 121 |
<!-- /.container --> |
| 122 |
</nav> |
| 123 |
|
| 124 |
|
| 125 |
<!-- Header --> |
| 126 |
<a class="anchor" name="about"></a> |
| 127 |
<div class="intro-header"> |
| 128 |
<div class="container-fluid"> |
| 129 |
|
| 130 |
<div class="row"> |
| 131 |
<div class="col-lg-push-2 col-lg-8"> |
| 132 |
<div class="intro-message"> |
| 133 |
<h1>Eclipse <span style="font-weight: 400">Collections</span></h1> |
| 134 |
<h3>- 满足你所有需求的集合包 -</h3> |
| 135 |
</div> |
| 136 |
</div> |
| 137 |
</div> |
| 138 |
|
| 139 |
</div> |
| 140 |
<!-- /.container --> |
| 141 |
|
| 142 |
</div> |
| 143 |
<!-- /.intro-header --> |
| 144 |
|
| 145 |
<!-- Page Content --> |
| 146 |
|
| 147 |
<a class="anchor" name="start"></a> |
| 148 |
<div class="content-section-a"> |
| 149 |
|
| 150 |
<div class="container-fluid"> |
| 151 |
<div class="row"> |
| 152 |
<div class="col-lg-5 col-sm-6"> |
| 153 |
<hr class="section-heading-spacer"> |
| 154 |
<div class="clearfix"></div> |
| 155 |
<h2 class="section-heading">Eclipse Collections入门须知</h2> |
| 156 |
<p class="lead">Eclipse Collections 是最完善的Java集合框架, 它会为你的Java 编程带来无限的乐趣。 |
| 157 |
<br><br>现在就使用你最喜欢的构建工具把它运用在你的Java项目中吧!</p> |
| 158 |
<object id="badge" data="https://snyk-widget.herokuapp.com/badge/mvn/org.eclipse.collections/eclipse-collections/badge.svg" type="image/svg+xml" style="vertical-align:middle"></object> |
| 159 |
<a href="http://search.maven.org/#search%7Cgav%7C1%7Cg:%22org.eclipse.collections%22%20AND%20a:%22eclipse-collections%22"><img src="https://maven-badges.herokuapp.com/maven-central/org.eclipse.collections/eclipse-collections/badge.svg"></a> |
| 160 |
<a href="https://github.com/eclipse/eclipse-collections/releases"><img src="https://img.shields.io/github/release/eclipse/eclipse-collections.svg"></a> |
| 161 |
<a href="https://github.com/eclipse/eclipse-collections/blob/master/LICENSE-EPL-1.0.txt"><img src="https://img.shields.io/badge/License-EPL-blue.svg"></a> |
| 162 |
<a href="https://github.com/eclipse/eclipse-collections/blob/master/LICENSE-EDL-1.0.txt"><img src="https://img.shields.io/badge/License-EDL-blue.svg"></a> |
| 163 |
</div> |
| 164 |
<div class="col-lg-7 col-sm-6"> |
| 165 |
<ul class="nav nav-tabs"> |
| 166 |
<li class="active"><a href="#maven" data-toggle="tab">Maven</a></li> |
| 167 |
<li><a href="#gradle" data-toggle="tab">Gradle</a></li> |
| 168 |
<li><a href="#ivy" data-toggle="tab">Ivy</a></li> |
| 169 |
<li><a href="#download" data-toggle="tab">Download</a></li> |
| 170 |
</ul> |
| 171 |
<div id="dependencies" class="tab-content"> |
| 172 |
<div class="tab-pane fade in active" id="maven"> |
| 173 |
<pre class="prettyprint"> |
| 174 |
<dependency> |
| 175 |
<groupId>org.eclipse.collections</groupId> |
| 176 |
<artifactId>eclipse-collections-api</artifactId> |
| 177 |
<version>11.0.0</version> |
| 178 |
</dependency> |
| 179 |
|
| 180 |
<dependency> |
| 181 |
<groupId>org.eclipse.collections</groupId> |
| 182 |
<artifactId>eclipse-collections</artifactId> |
| 183 |
<version>11.0.0</version> |
| 184 |
</dependency></pre> |
| 185 |
</div> |
| 186 |
<div class="tab-pane fade" id="gradle"> |
| 187 |
<pre class="prettyprint"> |
| 188 |
implementation 'org.eclipse.collections:eclipse-collections-api:11.0.0' |
| 189 |
implementation 'org.eclipse.collections:eclipse-collections:11.0.0'</pre> |
| 190 |
</div> |
| 191 |
<div class="tab-pane fade" id="ivy"> |
| 192 |
<pre class="prettyprint"> |
| 193 |
<dependency org="org.eclipse.collections" name="eclipse-collections-api" rev="11.0.0" /> |
| 194 |
<dependency org="org.eclipse.collections" name="eclipse-collections" rev="11.0.0" /></pre> |
| 195 |
</div> |
| 196 |
<div class="tab-pane fade" id="download"> |
| 197 |
<pre class="prettyprint"> |
| 198 |
<a target="_blank" href="http://mvnrepository.com/artifact/org.eclipse.collections/eclipse-collections-api/11.0.0">eclipse-collections-api-11.0.0.jar</a> |
| 199 |
<a target="_blank" href="http://mvnrepository.com/artifact/org.eclipse.collections/eclipse-collections/11.0.0">eclipse-collections-11.0.0.jar</a></pre> |
| 200 |
</div> |
| 201 |
|
| 202 |
</div> |
| 203 |
</div> |
| 204 |
</div> |
| 205 |
|
| 206 |
</div> |
| 207 |
<!-- /.container --> |
| 208 |
|
| 209 |
</div> |
| 210 |
<!-- Get Started --> |
| 211 |
|
| 212 |
<a class="anchor" name="concept"></a> |
| 213 |
<div class="content-section-b"> |
| 214 |
|
| 215 |
<div class="container-fluid"> |
| 216 |
|
| 217 |
<div class="row"> |
| 218 |
<div class="col-lg-push-7 col-lg-5 col-sm-push-6 col-sm-6"> |
| 219 |
<hr class="section-heading-spacer"> |
| 220 |
<div class="clearfix"></div> |
| 221 |
<h2 class="section-heading">简单明了而且功能强大的APIs</h2> |
| 222 |
<p class="lead">您可以直接调用集合中丰富的API让Java 8 Lambda表达式和方法引用发挥到极致。 |
| 223 |
</p> |
| 224 |
</div> |
| 225 |
<div class="col-lg-pull-5 col-lg-7 col-sm-pull-6 col-sm-6"> |
| 226 |
<ul class="nav nav-tabs"> |
| 227 |
<li class="active"><a href="#method" data-toggle="tab">Eclipse Collections和方法引用的实例</a></li> |
| 228 |
<li><a href="#ec" data-toggle="tab">Eclipse Collections和Lambda表达式的实例</a></li> |
| 229 |
<li><a href="#streams" data-toggle="tab">Java 8 Streams的实例</a></li> |
| 230 |
</ul> |
| 231 |
<div id="ec-vs-streams" class="tab-content"> |
| 232 |
<div class="tab-pane fade in active" id="method"> |
| 233 |
<pre class="prettyprint lang-java"> |
| 234 |
boolean anyPeopleHaveCats = |
| 235 |
this.people |
| 236 |
.anySatisfyWith(Person::hasPet, PetType.CAT); |
| 237 |
|
| 238 |
int countPeopleWithCats = |
| 239 |
this.people |
| 240 |
.countWith(Person::hasPet, PetType.CAT); |
| 241 |
|
| 242 |
MutableList<Person> peopleWithCats = |
| 243 |
this.people |
| 244 |
.selectWith(Person::hasPet, PetType.CAT)</pre> |
| 245 |
</div> |
| 246 |
<div class="tab-pane fade" id="ec"> |
| 247 |
<pre class="prettyprint lang-java"> |
| 248 |
boolean anyPeopleHaveCats = |
| 249 |
this.people |
| 250 |
.anySatisfy(person -> person.hasPet(PetType.CAT)); |
| 251 |
|
| 252 |
int countPeopleWithCats = |
| 253 |
this.people |
| 254 |
.count(person -> person.hasPet(PetType.CAT)); |
| 255 |
|
| 256 |
MutableList<Person> peopleWithCats = |
| 257 |
this.people |
| 258 |
.select(person -> person.hasPet(PetType.CAT));</pre> |
| 259 |
</div> |
| 260 |
<div class="tab-pane fade" id="streams"> |
| 261 |
<pre class="prettyprint lang-java"> |
| 262 |
boolean anyPeopleHaveCats = |
| 263 |
this.people |
| 264 |
.stream() |
| 265 |
.anyMatch(person -> person.hasPet(PetType.CAT)); |
| 266 |
|
| 267 |
long countPeopleWithCats = |
| 268 |
this.people |
| 269 |
.stream() |
| 270 |
.filter(person -> person.hasPet(PetType.CAT)) |
| 271 |
.count(); |
| 272 |
|
| 273 |
List<Person> peopleWithCats = |
| 274 |
this.people |
| 275 |
.stream() |
| 276 |
.filter(person -> person.hasPet(PetType.CAT)) |
| 277 |
.collect(Collectors.toList());</pre> |
| 278 |
</div> |
| 279 |
</div> |
| 280 |
<!-- /.tab-content --> |
| 281 |
</div> |
| 282 |
<!-- /.col --> |
| 283 |
</div> |
| 284 |
<!-- /.row --> |
| 285 |
|
| 286 |
</div> |
| 287 |
<!-- /.container --> |
| 288 |
|
| 289 |
</div> |
| 290 |
<!-- Rich and fluent API --> |
| 291 |
|
| 292 |
<div class="content-section-a"> |
| 293 |
|
| 294 |
<div class="container-fluid"> |
| 295 |
|
| 296 |
<div class="row"> |
| 297 |
<div class="col-lg-5 col-sm-6"> |
| 298 |
<hr class="section-heading-spacer"> |
| 299 |
<div class="clearfix"></div> |
| 300 |
<h2 class="section-heading">拥有不同种类的容器,其中包括<br>可变和不可变集合,原始类型集合, bimaps, multimaps 和 bags</h2> |
| 301 |
<p class="lead">通过Eclipse Collections的工厂方法,您可以轻松地创建各种集合类型。</p> |
| 302 |
</div> |
| 303 |
<div class="col-lg-7 col-sm-6"> |
| 304 |
<ul class="nav nav-tabs"> |
| 305 |
<li class="active"><a href="#mutable" data-toggle="tab">可变集合</a></li> |
| 306 |
<li><a href="#immutable" data-toggle="tab">不可变集合</a></li> |
| 307 |
<li><a href="#primitives" data-toggle="tab">原始类型集合</a></li> |
| 308 |
</ul> |
| 309 |
<div id="container-types" class="tab-content"> |
| 310 |
<div class="tab-pane fade in active" id="mutable"> |
| 311 |
<pre class="prettyprint lang-java"> |
| 312 |
//使用empty(), of(), with()方法初始化可变列表 |
| 313 |
MutableList<String> mutableListEmpty = |
| 314 |
Lists.mutable.empty(); |
| 315 |
MutableList<String> mutableListOf = |
| 316 |
Lists.mutable.of("One", "One", "Two", "Three"); |
| 317 |
MutableList<String> mutableListWith = |
| 318 |
Lists.mutable.with("One", "One", "Two", "Three"); |
| 319 |
|
| 320 |
//不同容器的示例 |
| 321 |
MutableSet<String> mutableSet = |
| 322 |
Sets.mutable.with("One", "One", "Two", "Three"); |
| 323 |
MutableBag<String> mutableBag = |
| 324 |
Bags.mutable.with("One", "One", "Two", "Three"); |
| 325 |
MutableStack<String> mutableStack = |
| 326 |
Stacks.mutable.with("One", "One", "Two", "Three"); |
| 327 |
MutableMap<String, String> mutableMap = |
| 328 |
Maps.mutable.with("key1", "value1", "key2", "value2", "key3", "value3"); |
| 329 |
MutableMultimap<String, String> multimapWithList = |
| 330 |
Multimaps.mutable.list.with("key1", "value1-1", "key1", "value1-2", "key2","value2-1"); |
| 331 |
MutableBiMap<String, String> mutableBiMap = |
| 332 |
BiMaps.mutable.with("key1", "value1", "key2", "value2", "key3", "value3");</pre> |
| 333 |
</div> |
| 334 |
<div class="tab-pane fade" id="immutable"> |
| 335 |
<pre class="prettyprint lang-java"> |
| 336 |
//使用empty(), of(), with()方法初始化不可变列表 |
| 337 |
ImmutableList<String> immutableListEmpty = |
| 338 |
Lists.immutable.empty(); |
| 339 |
ImmutableList<String> immutableListOf = |
| 340 |
Lists.immutable.of("One", "One", "Two", "Three"); |
| 341 |
ImmutableList<String> immutableListWith = |
| 342 |
Lists.immutable.with("One", "One", "Two", "Three"); |
| 343 |
|
| 344 |
//不同容器的示例 |
| 345 |
ImmutableSet<String> immutableSet = |
| 346 |
Sets.immutable.with("One", "One", "Two", "Three"); |
| 347 |
ImmutableBag<String> immutableBag = |
| 348 |
Bags.immutable.with("One", "One", "Two", "Three"); |
| 349 |
ImmutableStack<String> immutableStack = |
| 350 |
Stacks.immutable.with("One", "One", "Two", "Three"); |
| 351 |
ImmutableMap<String, String> immutableMap = |
| 352 |
Maps.immutable.with("key1", "value1", "key2", "value2", "key3", "value3"); |
| 353 |
ImmutableMultimap<String, String> immutableMultimapWithList = |
| 354 |
Multimaps.immutable.list.with("key1", "value1-1", "key1", "value1-2", "key2","value2-1"); |
| 355 |
ImmutableBiMap<String, String> immutableBiMap = |
| 356 |
BiMaps.immutable.with("key1", "value1", "key2", "value2", "key3", "value3");</pre> |
| 357 |
</div> |
| 358 |
<div class="tab-pane fade" id="primitives"> |
| 359 |
<pre class="prettyprint lang-java"> |
| 360 |
//全部8种原始类型都有相应的可变与不可变的Lists, Sets, Bags, Stacks 和 Maps |
| 361 |
MutableIntList intList = |
| 362 |
IntLists.mutable.of(1, 2, 3); |
| 363 |
MutableLongList longList = |
| 364 |
LongLists.mutable.of(1L, 2L, 3L); |
| 365 |
MutableCharList charList = |
| 366 |
CharLists.mutable.of('a', 'b', 'c'); |
| 367 |
MutableShortList shortList = |
| 368 |
ShortLists.mutable.of((short)1, (short)2, (short)3); |
| 369 |
MutableByteList byteList = |
| 370 |
ByteLists.mutable.of((byte)1, (byte)2, (byte)3); |
| 371 |
MutableBooleanList booleanList = |
| 372 |
BooleanLists.mutable.of(true, false); |
| 373 |
MutableFloatList floatList = |
| 374 |
FloatLists.mutable.of(1.0f, 2.0f, 3.0f); |
| 375 |
MutableDoubleList doubleList = |
| 376 |
DoubleLists.mutable.of(1.0, 2.0, 3.0); |
| 377 |
|
| 378 |
//使用IntInterval创建指定范围的整数集合 |
| 379 |
IntInterval oneTo10 = |
| 380 |
IntInterval.fromTo(1, 10); // 从 1 到 10 的整数 |
| 381 |
// [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] |
| 382 |
IntInterval oneTo10By3 = |
| 383 |
IntInterval.fromToBy(1, 10, 3); // 从 1 到 10 间隔为3的整数 |
| 384 |
// [1, 4, 7, 10] |
| 385 |
IntInterval oddsFrom1To10 = |
| 386 |
IntInterval.oddsFromTo(1, 10); // 从 1 到 10 的奇数 |
| 387 |
// [1, 3, 5, 7, 9] |
| 388 |
IntInterval evensFrom1To10 = |
| 389 |
IntInterval.evensFromTo(1, 10); // 从 1 到 10 的偶数 |
| 390 |
// [2, 4, 6, 8, 10]</pre> |
| 391 |
</div> |
| 392 |
</div> |
| 393 |
<!-- /.tab-content --> |
| 394 |
</div> |
| 395 |
<!-- /.col --> |
| 396 |
</div> |
| 397 |
<!-- /.row --> |
| 398 |
|
| 399 |
</div> |
| 400 |
<!-- /.container --> |
| 401 |
|
| 402 |
</div> |
| 403 |
<!-- Container Types --> |
| 404 |
|
| 405 |
<a class="anchor" name="memory"></a> |
| 406 |
<div class="content-section-b"> |
| 407 |
|
| 408 |
<div class="container-fluid"> |
| 409 |
|
| 410 |
<div class="row"> |
| 411 |
<div class="col-lg-push-6 col-lg-6 col-sm-push-6 col-sm-6"> |
| 412 |
<hr class="section-heading-spacer"> |
| 413 |
<div class="clearfix"></div> |
| 414 |
<h2 class="section-heading">使用高效的容器来降低内存空间</h2> |
| 415 |
<p class="lead">Eclipse Collections拥有内存优化的Sets, Maps和原始类型集合。 </p> |
| 416 |
</div> |
| 417 |
<div class="col-lg-pull-6 col-lg-6 col-sm-pull-6 col-sm-6"> |
| 418 |
<ul class="nav nav-tabs"> |
| 419 |
<li class="active"><a href="#set" data-toggle="tab">Sets</a></li> |
| 420 |
<li><a href="#map" data-toggle="tab">Maps</a></li> |
| 421 |
<li><a href="#ints" data-toggle="tab">原始类型集合</a></li> |
| 422 |
</ul> |
| 423 |
<div id="memory" class="tab-content"> |
| 424 |
<div class="tab-pane fade in active" id="set"> |
| 425 |
<img class="img-responsive" src="../img/set.png" alt=""> |
| 426 |
</div> |
| 427 |
<div class="tab-pane fade" id="map"> |
| 428 |
<img class="img-responsive" src="../img/map.png" alt=""> |
| 429 |
</div> |
| 430 |
<div class="tab-pane fade" id="ints"> |
| 431 |
<img class="img-responsive" src="../img/ints.png" alt=""> |
| 432 |
</div> |
| 433 |
</div> |
| 434 |
</div> |
| 435 |
</div> |
| 436 |
|
| 437 |
</div> |
| 438 |
<!-- /.container --> |
| 439 |
|
| 440 |
</div> |
| 441 |
<!-- Memory footprint --> |
| 442 |
|
| 443 |
<a class="anchor" name="learn"></a> |
| 444 |
<div class="content-section-a"> |
| 445 |
|
| 446 |
<div class="container-fluid"> |
| 447 |
|
| 448 |
<div class="row"> |
| 449 |
<div class="col-lg-5 col-sm-6"> |
| 450 |
<hr class="section-heading-spacer"> |
| 451 |
<div class="clearfix"></div> |
| 452 |
<h2 class="section-heading">通过Kata学习Eclipse Collections</h2> |
| 453 |
<p class="lead"> |
| 454 |
请参考<a href="https://github.com/eclipse/eclipse-collections-kata">Eclipse Collections Kata</a>, 一种学习Eclipse Collections常用方法的有趣途径。 |
| 455 |
我们给这个kata练习定制了一系列失败的单元测试。 |
| 456 |
你的任务是运用Eclipse Collections提供的方法让单元测试通过。 |
| 457 |
</p> |
| 458 |
</div> |
| 459 |
<div class="col-lg-7 col-sm-6"> |
| 460 |
<ul class="nav nav-tabs"> |
| 461 |
<li class="active"><a href="#exercise" data-toggle="tab">练习示例</a></li> |
| 462 |
<li><a href="#solution" data-toggle="tab">解答示例</a></li> |
| 463 |
</ul> |
| 464 |
<div class="tab-content"> |
| 465 |
<div class="tab-pane fade in active" id="exercise"> |
| 466 |
<pre class="prettyprint lang-java"> |
| 467 |
@Test |
| 468 |
public void getFirstNamesOfAllPeople() |
| 469 |
{ |
| 470 |
MutableList<Person> people = this.people; |
| 471 |
MutableList<String> firstNames = null; //用MutableList上的转化方法来替代null。 |
| 472 |
MutableList<String> expectedFirstNames = |
| 473 |
Lists.mutable.with("Mary", "Bob", "Ted", "Jake", "Barry", "Terry", "Harry", "John"); |
| 474 |
Assert.assertEquals(expectedFirstNames, firstNames); |
| 475 |
}</pre> |
| 476 |
</div> |
| 477 |
<div class="tab-pane fade" id="solution"> |
| 478 |
<pre class="prettyprint lang-java"> |
| 479 |
@Test |
| 480 |
public void getFirstNamesOfAllPeople() |
| 481 |
{ |
| 482 |
MutableList<Person> people = this.people; |
| 483 |
MutableList<String> firstNames = people.collect(Person::getFirstName); |
| 484 |
MutableList<String> expectedFirstNames = |
| 485 |
Lists.mutable.with("Mary", "Bob", "Ted", "Jake", "Barry", "Terry", "Harry", "John"); |
| 486 |
Assert.assertEquals(expectedFirstNames, firstNames); |
| 487 |
}</pre> |
| 488 |
</div> |
| 489 |
</div> |
| 490 |
<!-- /.tab-content --> |
| 491 |
</div> |
| 492 |
<!-- /.col --> |
| 493 |
</div> |
| 494 |
<!-- /.row --> |
| 495 |
|
| 496 |
</div> |
| 497 |
<!-- /.container --> |
| 498 |
|
| 499 |
</div> |
| 500 |
<!-- Kata --> |
| 501 |
|
| 502 |
<a class="anchor" name="history"></a> |
| 503 |
<div class="content-section-b"> |
| 504 |
|
| 505 |
<div class="container-fluid"> |
| 506 |
|
| 507 |
<h2 class="section-heading">Eclipse Collections的历史</h2> |
| 508 |
<p class="lead"> |
| 509 |
Eclipse Collections起源于2004年在高盛公司内部开发的一个名为Caramel的集合框架。 |
| 510 |
|
| 511 |
自那以后,这个框架不断发展并在2012年开源成为GitHub中一个叫做 |
| 512 |
<a href="https://github.com/goldmansachs/gs-collections">GS Collections</a>的项目。 |
| 513 |
<br><br> |
| 514 |
许多 |
| 515 |
<a href="https://github.com/eclipse/eclipse-collections/wiki/Conference-talks-and-meetups">会议</a>中都有介绍GS Collections。 |
| 516 |
包括2012的JVM Summit和2014的JavaOne。 |
| 517 |
此外,在2014年的 |
| 518 |
<a href="http://www.infoq.com/presentations/java-streams-scala-parallel-collections">QCon New York</a>上还介绍了在Java 8,Scala和GS Collections的平行惰性实现之间的性能比较。 |
| 519 |
<a href="https://github.com/eclipse/eclipse-collections/wiki/Articles">关于GS Collections的文章</a> |
| 520 |
(<a href="http://www.infoq.com/cn/articles/gs-collections-examples-tutorial-part1/">第一部分</a> / |
| 521 |
<a href="http://www.infoq.com/cn/articles/gs-collections-examples-tutorial-part2">第二部分</a>) |
| 522 |
已经刊登在InfoQ.com, 文中通过实例展示了集合框架的一些功能,并且还向GS Collections的创始人进行了采访。 |
| 523 |
<br><br> |
| 524 |
|
| 525 |
多年来,大约40多名来自同一家公司的开发人员对集合框架做出了贡献。 |
| 526 |
<br><br> |
| 527 |
|
| 528 |
为了最大限度地发挥开源项目的最佳特质,GS Collections已经被迁移到Eclipse Foundation,并在2015年被重新命名为Eclipse Collections。 |
| 529 |
现在这个框架完全向大家开放,接受贡献! |
| 530 |
</p> |
| 531 |
</div> |
| 532 |
</div> |
| 533 |
<!-- History --> |
| 534 |
|
| 535 |
<a class="anchor" name="refGuide"></a> |
| 536 |
<div class="content-section-a"> |
| 537 |
<div class="container-fluid"> |
| 538 |
<h2 class="section-heading">参考指南</h2> |
| 539 |
<p class="lead"> |
| 540 |
GitHub上有Eclipse Collections的详细参考指南: |
| 541 |
<a href="https://github.com/eclipse/eclipse-collections/blob/master/docs/guide.md#eclipse-collections-reference-guide">参考指南</a>. |
| 542 |
</p> |
| 543 |
</div> |
| 544 |
<!-- /.container --> |
| 545 |
|
| 546 |
</div> |
| 547 |
<!-- Reference Guide --> |
| 548 |
|
| 549 |
<a class="anchor" name="sourceCode"></a> |
| 550 |
<div class="content-section-b"> |
| 551 |
<div class="container-fluid"> |
| 552 |
<h2 class="section-heading">源代码</h2> |
| 553 |
<p class="lead"> |
| 554 |
在GitHub上可以找到<a href="https://github.com/eclipse/eclipse-collections">Eclipse Collections</a>的源代码. |
| 555 |
</p> |
| 556 |
</div> |
| 557 |
<!-- /.container --> |
| 558 |
</div> |
| 559 |
<!-- Source Code --> |
| 560 |
|
| 561 |
<a class="anchor" name="contribute"></a> |
| 562 |
<div class="content-footer"> |
| 563 |
|
| 564 |
<div class="container-fluid"> |
| 565 |
|
| 566 |
<div class="row"> |
| 567 |
<div class="col-lg-4 col-sm-4"> |
| 568 |
<h3>贡献</h3> |
| 569 |
<p class="regular"> |
| 570 |
欢迎大家来贡献! |
| 571 |
<br><br> |
| 572 |
请参考<a href="https://github.com/eclipse/eclipse-collections/wiki/Roadmap">这里</a>的Eclipse Collections项目路线图. |
| 573 |
<br><br> |
| 574 |
我们通过GitHub的pull请求接受贡献。 |
| 575 |
有关详细信息, 请参阅<a href="https://github.com/eclipse/eclipse-collections/blob/master/CONTRIBUTING.md">如何贡献</a> |
| 576 |
</p> |
| 577 |
</div> |
| 578 |
<div class="col-lg-4 col-sm-4"> |
| 579 |
<h3>最新消息</h3> |
| 580 |
<p class="regular">Eclipse Collections 11.0.0 版本<a href="https://github.com/eclipse/eclipse-collections/releases/tag/11.0.0">发布</a> <a class="light">(Nov 23rd 2020)</a></p> |
| 581 |
<p class="regular">Eclipse Collections 10.4.0 版本<a href="https://github.com/eclipse/eclipse-collections/releases/tag/10.4.0">发布</a> <a class="light">(Aug 20th 2020)</a></p> |
| 582 |
<p class="regular">Eclipse Collections 10.3.0 版本<a href="https://github.com/eclipse/eclipse-collections/releases/tag/10.3.0">发布</a> <a class="light">(Aug 8th 2020)</a></p> |
| 583 |
<p class="regular">Eclipse Collections 10.2.0 版本<a href="https://github.com/eclipse/eclipse-collections/releases/tag/10.2.0">发布</a> <a class="light">(Feb 11th 2020)</a></p> |
| 584 |
<p class="regular">Eclipse Collections 10.1.0 版本<a href="https://github.com/eclipse/eclipse-collections/releases/tag/10.1.0">发布</a> <a class="light">(Dec 4th 2019)</a></p> |
| 585 |
<p class="regular">Eclipse Collections 10.0.0 版本<a href="https://github.com/eclipse/eclipse-collections/releases/tag/10.0.0">发布</a> <a class="light">(Jul 10th 2019)</a></p> |
| 586 |
</div> |
| 587 |
<div class="col-lg-4 col-sm-4"> |
| 588 |
<h3>社区链接集合</h3> |
| 589 |
<p class="regular">Eclipse PMI: <a href="https://projects.eclipse.org/projects/technology.collections">eclipse project management infrastructure</a></p> |
| 590 |
<p class="regular">GitHub: <a href="https://github.com/eclipse/eclipse-collections">eclipse-collections</a></p> |
| 591 |
<p class="regular">Issues: <a href="https://github.com/eclipse/eclipse-collections/issues">GitHub issues</a></p> |
| 592 |
<p class="regular">Mailing lists: <a href="https://dev.eclipse.org/mailman/listinfo/collections-dev">collections-dev</a> mailing list</p> |
| 593 |
<p class="regular">Wiki: <a href="https://github.com/eclipse/eclipse-collections/wiki">GitHub wiki</a></p> |
| 594 |
<p class="regular">Forum: <a href="https://www.eclipse.org/forums/index.php?t=thread&frm_id=329">Eclipse Collections Forum</a></p> |
| 595 |
<p class="regular">StackOverflow: tag with <a href="http://stackoverflow.com/questions/tagged/eclipse-collections">eclipse-collections</a></p> |
| 596 |
</div> |
| 597 |
<!-- /.col --> |
| 598 |
</div> |
| 599 |
<!-- /.row --> |
| 600 |
|
| 601 |
</div> |
| 602 |
<!-- /.container --> |
| 603 |
|
| 604 |
</div> |
| 605 |
<!-- Container Types --> |
| 606 |
|
| 607 |
|
| 608 |
<div class="banner"> |
| 609 |
|
| 610 |
<div class="container-fluid"> |
| 611 |
|
| 612 |
<div class="row"> |
| 613 |
<div class="col-lg-12"> |
| 614 |
<h3>- 更多的功能,更少的浪费 -</h3> |
| 615 |
</div> |
| 616 |
</div> |
| 617 |
|
| 618 |
</div> |
| 619 |
<!-- /.container --> |
| 620 |
|
| 621 |
</div> |
| 622 |
<!-- /.banner --> |
| 623 |
|
| 624 |
<!-- Footer --> |
| 625 |
<footer> |
| 626 |
<div class="container-fluid"> |
| 627 |
<div class="row"> |
| 628 |
<div class="col-lg-12"> |
| 629 |
<ul class="list-inline"> |
| 630 |
<li> |
| 631 |
<p class="copyright text-muted small">Copyright © 2018 The Eclipse Foundation. All Rights Reserved. </p> |
| 632 |
</li> |
| 633 |
<li class="footer-menu-divider">⋅</li> |
| 634 |
<li> |
| 635 |
<a class="small" href="http://www.eclipse.org">Eclipse Foundation</a> |
| 636 |
</li> |
| 637 |
<li class="footer-menu-divider">⋅</li> |
| 638 |
<li> |
| 639 |
<a class="small" href="http://www.eclipse.org/legal">Legal</a> |
| 640 |
</li> |
| 641 |
<li class="footer-menu-divider">⋅</li> |
| 642 |
<li> |
| 643 |
<a class="small" href="http://www.eclipse.org/legal/privacy.php">Privacy</a> |
| 644 |
</li> |
| 645 |
<li class="footer-menu-divider">⋅</li> |
| 646 |
<li> |
| 647 |
<a class="small" href="http://www.eclipse.org/legal/termsofuse.php">Terms of Use</a> |
| 648 |
</li> |
| 649 |
<li class="footer-menu-divider">⋅</li> |
| 650 |
<li> |
| 651 |
<a class="small" href="http://www.eclipse.org/legal/copyright.php">Copyright Agent</a> |
| 652 |
</li> |
| 653 |
</ul> |
| 654 |
</div> |
| 655 |
</div> |
| 656 |
</div> |
| 657 |
</footer> |
| 658 |
|
| 659 |
<!-- jQuery --> |
| 660 |
<script src="https://code.jquery.com/jquery-2.2.0.min.js"></script> |
| 661 |
|
| 662 |
<!-- Bootstrap Core JavaScript --> |
| 663 |
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha256-KXn5puMvxCw+dAYznun+drMdG1IFl3agK0p/pqT9KAo= sha512-2e8qq0ETcfWRI4HJBzQiA3UoyFk6tbNyG+qSaIBZLyW9Xf3sWZHN/lxe9fTh1U45DpPf07yj94KsUHHWe4Yk1A==" crossorigin="anonymous"></script> |
| 664 |
|
| 665 |
<!-- Google Code Prettify --> |
| 666 |
<script src="https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js?skin=sunburst"></script> |
| 667 |
</body> |
| 668 |
|
| 669 |
</html> |