定制 xp-framework/collections 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

xp-framework/collections

最新稳定版本:v10.1.0

Composer 安装命令:

composer require xp-framework/collections

包简介

Generic collections for the XP Framework

关键字:

README 文档

README

Build status on GitHub XP Framework Module BSD Licence Requires PHP 7.0+ Supports PHP 8.0+ Latest Stable Version

Generic collections for the XP Framework

API

package util.collections {
  public interface util.collections.IList<T>
  public interface util.collections.Map<K, V>
  public interface util.collections.Set<T>

  public class util.collections.HashSet<T>
  public class util.collections.HashTable<K, V>
  public class util.collections.LRUBuffer<T>
  public class util.collections.Pair<K, V>
  public class util.collections.Queue<T>
  public class util.collections.Stack<T>
  public class util.collections.Vector<T>
}

Example: HashTable

$map= create('new util.collections.HashTable<string, com.example.Customer>');
$empty= $map->isEmpty();
$size= $map->size();

// Write values
$map['@example']= new Customer(0, 'Example customer');
$map->put('@friebe', new Customer(1, 'Timm Friebe'));

// Raises an exception
$map['@invalid']= new Date();

// Access
$customer= $map['@example'];
$customer= $map->get('@example');

// Test
if (isset($map['@example'])) {
  // ...
}

// Will return NULL
$customer= $map['@nonexistant'];

// Remove
unset($map['@example']);
$map->remove('@example');

// Iteration
foreach ($map as $pair) {
  echo $pair->key, ': ', $pair->value->toString(), "\n";
}

Example: Vector

$list= create('new util.collections.Vector<com.example.Customer>');
$empty= $list->isEmpty();
$size= $list->size();

// Write values
$list[]= new Customer(0, 'Example customer');
$list->add(new Customer(1, 'Timm Friebe'));

$list[0]= new Customer(0, 'Example customer');
$list->set(1, new Customer(1, 'Timm Friebe'));

// Raises an exception
$list[0]= new Date();

// Access
$customer= $list[0];
$customer= $list->get(0);

// Test
if (isset($list[1])) {
  // ...
}

// Will return NULL
$customer= $list[1];

// Remove
unset($list[1]);
$list->remove(1);

// Iteration
foreach ($list as $customer) {
  echo $customer->toString(), "\n";
}

Further reading

统计信息

  • 总下载量: 124.63k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 6
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2015-11-08