22
33[ ![ Build Status] ( https://travis-ci.org/wxxiong6/php-ext-arraylist.svg?branch=master )] ( https://travis-ci.org/wxxiong6/php-ext-arraylist )
44
5- ArrayList是一个使用使用C实现类似于Java ArrayList的扩展 。
6- 适用于大数组环境,提高内存使用率,比原生array使用更少的内存 。
5+ ArrayList是一个使用C实现类似于Java ArrayList的高性能扩展 。
6+ 适用于构建超大数组,比原生数组创建数组使用时间更快,内存占用量更少 。
77
88## Requirement
9+
910php7.0 +
1011
1112## Install
12- # Compile ArrayList in Linux mac
13+
14+ ### Compile ArrayList in Linux mac
1315
1416``` shell
1517phpize
1820make install
1921```
2022
23+ ### windows
24+
25+ 下载源码自行编译
26+
2127## Document
28+
2229``` php
2330ArrayList implements ArrayAccess {
2431 /* 方法 */
@@ -33,13 +40,16 @@ ArrayList implements ArrayAccess {
3340```
3441
3542## More
43+
3644``` php
45+
3746$ret = new ArrayList();
3847$ret[] = 1; // 也可以使用 $ret->add(1);
3948$ret[0]; // 也可以使用 $ret->get(0);
4049$ret->count();
4150$ret->getSize();
4251$ret->toArray();
52+
4353```
4454
4555``` php
@@ -48,17 +58,17 @@ $ret2 = new ArrayList();
4858$ret3 = new ArrayList();
4959for ($i = 0; $i < SIZE; $i++)
5060{
51- $ret2->add((string)$i);
52- $ret3->add((string)(SIZE-$i));
61+ $ret2->add((string)$i);
62+ $ret3->add((string)(SIZE-$i));
5363}
5464$ret = new Arraylist();
5565$ret->add($ret2);
5666$ret->add($ret3);
5767for ($i = 0; $i < $ret->count(); $i++) {
58- for($j = 0; $j < $ret->get($i)->count(); $j++) {
59- var_dump($ret->get($i)->get($j));
60- }
61- echo "\n";
68+ for($j = 0; $j < $ret->get($i)->count(); $j++) {
69+ var_dump($ret->get($i)->get($j));
70+ }
71+ echo "\n";
6272}
6373```
6474
@@ -72,6 +82,7 @@ for ($i = 0; $i< $ret->count(); $i++) {
7282 }
7383}
7484```
85+
7586## 与数组写入性能对比
7687
7788Testing size: 1,000
0 commit comments