当前位置: 首页 > news >正文

快站建站wordpress会员中心

快站建站,wordpress会员中心,网站标题 关键词 描述之间的关系,企业网站平台建设咨询合同java fastutil针对我最近在GNU Trove库上发表的《 发现Java原始资源集合的处理 》一书 #xff0c; TheAlchemist指出了fastutil优于trove的一些优点#xff1a;“我更喜欢fastutil#xff08; http://fastutil.di.unimi.it/ #xff09;#xff0c;因为它仍在积极开发中 TheAlchemist指出了fastutil优于trove的一些优点“我更喜欢fastutil http://fastutil.di.unimi.it/ 因为它仍在积极开发中具有更多功能支持大尺寸 2 ^ 32并且具有更好的文档。” 阿提拉-米哈伊·巴拉兹已借调第二个“I TheAlchemist的建议为fastutil此 这是一个很棒的图书馆。” 在这篇文章中我从以前对trove的一些相同角度研究了fastutil 。 在fastutil主页上将fastutil描述为Java TM Collections Framework的扩展它提供了“特定于类型的映射集合列表和队列具有较小的内存占用以及快速的访问和插入”以及“大型64位数组设置和列表以及用于二进制和文本文件的快速实用的I / O类。” fastutil的许可证是Apache License版本2 而fastutil的当前版本需要Java 7或更高版本。 当前截至撰写本文时 Java 6和Java 5也可以下载“未维护”的fastutil版本。 通过与标准Java集合使用的API调用相同的API调用来完成将元素添加到FastUtil集合的操作如下面的代码清单所示该代码列表比较了将元素插入JDK ArrayList和将元素插入FastUtil DoubleArrayList的过程 。 使用JDK插入双打和使用FastUtil DoubleArrayList插入双打 /*** Demonstrate standard JDK {code ArrayListDouble}* with some JDK 8 functionality.*/ public void demonstrateJdkArrayListForDoubles() {final ArrayListDouble doubles new ArrayList();doubles.add(15.5);doubles.add(24.4);doubles.add(36.3);doubles.add(67.6);doubles.add(10.0);out.println(JDK ArrayListDouble:);out.println(\tDoubles List: doubles); }/*** Demonstrate use of DoubleArrayList and show how* similar using it is to using {code ArrayListDouble}.*/ public void demonstrateFastUtilArrayListForDoubles() {// Demonstrate adding elements to DoubleArrayList is// exactly like adding elements to ArrayListDouble.final DoubleArrayList doubles new DoubleArrayList();doubles.add(15.5);doubles.add(24.4);doubles.add(36.3);doubles.add(67.6);doubles.add(10.0);out.println(FastUtil DoubleArrayList:); // DoubleArrayList overrides toString()out.println(\tDoubles List: doubles); } 当执行上述两种方法时写入标准输出的双精度项列表看起来完全相同即使用相同的方括号括住逗号分隔的双精度值。 FastUtil集合倾向于实现适当的JDK集合接口。 例如刚刚演示的类DoubleArrayList实现了几个接口包括Collection Double和List Double。 事实证明DoubleArrayList还实现了it.unimi.dsi.fastutil.doubles.DoubleStack和it.unimi.dsi.fastutil.Stack Double 。 下一个代码清单中展示了使用此类作为堆栈的能力。 使用FastUtil的DoubleArrayList作为堆栈 /*** Demonstrate FastUtils Double Stack.** FastUtils DoubleStack allows access to its* contents via push, pop, and peek. It is declared* as a DoubleArrayList type here so that the size()* method is available without casting.*/ public void demonstrateFastUtilDoubleStack() {final DoubleArrayList stack new DoubleArrayList();stack.push(15.5);stack.push(17.3);stack.push(16.6);stack.push(2.2);out.println(FastUtil Stack of Doubles);out.println(\tPeek: stack.peek(0) ; After Size: stack.size());out.println(\tPop: stack.pop() ; After Size: stack.size());out.println(\tPeek: stack.peek(0) ; After Size: stack.size()); } 正如我在Trove上的博客文章中所讨论的那样Trove提供了一个gnu.trove.TCollections类该类与java.util.Collections类似子集。 FastUtil提供了类似的功能但是这种提供静态方法以对FastUtil集合起作用的方法通过静态方法被分为特定于类型的类型和特定于结构的类而不是在具有静态方法的单个类中。 下一个代码清单演示将这些特定于类型和特定于结构的类之一与静态方法IntSets结合使用 并将其与FastUtil IntLinkedOpenHashSet结合使用。 顾名思义 IntSets类提供了“使用[int]特定的集可以做有用的事情的静态方法和对象。” 将IntSet与IntLinkedOpenHashSet一起使用 /*** Demonstrate one of FastUtils equivalents of the* java.util.Collections class. FastUtil separates its* grouping of static methods into classes that are* specific to the data type of the collection and to* the data structure type of the collection.*/ public void demonstrateFastUtilCollectionsClass() {final IntLinkedOpenHashSet integers new IntLinkedOpenHashSet();integers.add(5);integers.add(7);integers.add(3);integers.add(1);final IntSet unmodifiableIntegers IntSets.unmodifiable(integers);out.println(Unmodifiable Integers:);out.println(\tClass: unmodifiableIntegers.getClass().getCanonicalName());try{unmodifiableIntegers.add(15);}catch (Exception ex){out.println(\tException caught: ex);} } FastUtil支持使用显式迭代器和Java SE 5引入的for-each循环的标准Java迭代方法。 因为FastUtil集合实现java.lang.Iterable所以FastUtil集合甚至使用.forEach支持JDK 8样式 假定代码是在JDK 8上构建和运行的。 这些将在下一个代码清单中进行演示。 以标准Java样式迭代FastUtil集合 /*** Demonstrate traditional Java iteration of a* FastUtil collection.*/ public void demonstrateIterationWithIterator() {final LongOpenHashSet longs new LongOpenHashSet();longs.add(15);longs.add(6);longs.add(12);longs.add(13);longs.add(2);final LongIterator longIterator longs.iterator();while (longIterator.hasNext()){final long longValue longIterator.next();out.print(longValue );} }/*** Demonstrate iteration of a FastUtil collection* using Javas enhanced for-each approach.*/ public void demonstrateIterationWithForEach() {final LongLinkedOpenHashSet longs new LongLinkedOpenHashSet();longs.add(15);longs.add(6);longs.add(12);longs.add(13);longs.add(2);for (final long longValue : longs){out.println(longValue );} }/*** Demonstrate iteration of a FastUtil collection* using JDK 8 .forEach approach.*/ public void demonstrateIterationWithJdk8ForEach() {final LongLinkedOpenHashSet longs new LongLinkedOpenHashSet();longs.add(15);longs.add(6);longs.add(12);longs.add(13);longs.add(2);longs.forEach(longValue - out.print(longValue )); }与FastUtil相关的其他观察 由于FastUtil集合实现标准的JDK 8集合接口因此可以很容易地使用熟悉的Java习惯用法来获取和使用这些API。 FastUtil集合通常提供一个构造函数该构造函数接受基础数据类型的数组以及重写的toArray方法和特定于类型的方法例如toDoubleArray [用于双向定位的集合]以数组形式提供其数据元素。原语。 FastUtil集合通常提供显式重写的toString()实现这些实现允许像JDK集合一样轻松编写各个数据元素并且与Java数组需要Arrays.toString方法不同。 FastUtil的Java程序包通常按原始类型进行组织并且该原始类型的各种数据结构类型的特定实现都在同一程序包中进行。 例如程序包的名称类似it.unimi.dsi.fastutil.doubles it.unimi.dsi.fastutil.ints等。 因为每个FastUtil集合都特定于特定的原始数据类型所以每个集合都不需要通用参数并且没有与通用相关的问题例如擦除。 我还没有看到FastUtil像Trove一样利用特定于类型的集合的特定于类型的方法这可能是因为FastUtil更紧密地实现了相应的Java集合接口。 学习使用FastUtil时 FastUtil的Javadoc API文档可能是最佳的起点。 在FastUtil的基于Javadoc的API文档中类接口枚举和包通常都记录得很好。 结论 与Trove一样FastUtil是一个库可以用来更有效地就内存和性能而言与Java集合一起使用。 Trove似乎曾经是众多选择中最受欢迎的而FastUtil也许是目前最受欢迎的原因包括TheAlchemist引用的那些理由“仍在积极开发中具有更多功能支持大尺寸 2 ^ 32 并具有更好的文档。” 除了Trove和FastUtil之外 类似的库还包括Java的高性能基元集合 HPPC Koloboke Goldman Sachs集合 Mahout集合和Javolution 。 翻译自: https://www.javacodegeeks.com/2016/01/leaner-java-collections-with-fastutil.htmljava fastutil
http://wiki.neutronadmin.com/news/347233/

相关文章:

  • 网站策划初级方案模板wordpress为什么放弃
  • 长沙中小企业网站建设建设网站怎么提需求
  • 合同 制作 网站网上购物商城排名
  • 网站建设报价新鸿儒好看的网站页面
  • 北京网站优化流程网络推广app是违法的吗
  • 移动网站建设平台工程建设网站导航图
  • 给公司建网站 深圳wordpress链接数据库失败
  • 建设网站 如何给文件命名wordpress克隆
  • 成都好的网站设计公司唐山网站网站建设
  • 做网站单位页面设计的对称方法包括哪几种形式
  • 东营网站建设seowordpress 安装七牛
  • 企业网站信息化建设网站建设中所涉及的所有链接建设
  • 医院网站建设情况汇报网络管理培训课程
  • 网站设计价格大概是平面设计公司一般做什么
  • 视频模板在线制作网站软件专业做学校网站论文怎么选题
  • c 网站开发例子如何建立国际网站
  • 专业网站制作案例做简历模板的网站都有哪些
  • 西安手机网站开发拓什么设计网站
  • 成都市建设学校网站网络科技公司网站
  • 企业网站建设的实践意义上海网络维护找哪家好
  • 扬中招聘信息网优化营商环境心得体会个人
  • 手机网站设计报价东莞营销网站建设直播
  • 网站上社保做增员怎么做做网站要营业执照吗
  • seo黑帽排名站长工具的使用seo综合查询运营
  • 网站公司怎么做推广网页版式设计案例
  • we建站电脑网页无法打开是什么原因
  • 南城网站建设多少钱湖北省建设信息网站
  • 南宁网站建设专家网站设计需要哪些
  • 企业网站的首页设计模板wordpress图片域名
  • 网站相对路径和绝对路径做新得网站可以换到原来得域名嘛