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

如何自建公司网站北京百度seo排名点击器

如何自建公司网站,北京百度seo排名点击器,网站这么绑定到域名,做游戏网站要多少钱在看 Alibaba 开发手册时遇到 PECS 原则,刚开始阅读时感觉比较绕,也搜索了一些博文参考,个人觉得 Stackoverflow 的这篇文章比较实用 —— What is PECS (Producer Extends Consumer Super)? 后面结合 JDK 源码梳理了下 // java/util/List…

在这里插入图片描述
在看 Alibaba 开发手册时遇到 PECS 原则,刚开始阅读时感觉比较绕,也搜索了一些博文参考,个人觉得 Stackoverflow 的这篇文章比较实用 —— What is PECS (Producer Extends Consumer Super)?

后面结合 JDK 源码梳理了下

// java/util/List.class
public interface List<E> extends Collection<E> {......default void sort(Comparator<? super E> c) {Object[] a = this.toArray();Arrays.sort(a, (Comparator) c);ListIterator<E> i = this.listIterator();for (Object e : a) {i.next();i.set((E) e);}}
}

对于 sort 方法,参数 Comparator<? super E> c 是消费者,c 会获取从该集合 List<E> 中获取元素进行比较。比较器使用的是 Comparator<? super E> c ,因为其 int compare(T o1, T o2) 方法中参数类型 T 是 E 的父类,那么从集合 List<E> 中获取的元素任何 E 类型的方法都可以调用该 int compare(T o1, T o2) 方法进行比较。
例如,

public static class Animal {public String name; // The name of the animal
}public static class Cat extends Animal {public int speed; // The Running Speed of Catspublic Cat(String name, int speed) {this.speed = speed;super.name = name;}@Overridepublic String toString() {return name;}
}public static void main(String[] args) {List<Cat> list = Lists.newArrayList(new Cat("Cookie", 3), new Cat("Trifle", 2));// Comparator<Animal> list.sort(Comparator.comparing((Animal o) -> o.name)); // Cookie, Triflelist.forEach(System.err::println);// Comparator<Cat>list.sort(Comparator.comparing((Cat o) -> o.speed)); // Trifle, Cookielist.forEach(System.err::println);
}

对于 List<Cat>sort 时比较器可以为 Comparator<Animal> ,Cat 继承 Animal,可以把 Cat 作为 Animal消费。更甚至比较器可以为 Comparator<Object>

可以想象一下,如果 sort 参数形式为(Comparator<? extends E> c),从 List<E> 中获取元素只能保证为 E 类型,但比较器 int compare(T o1, T o2) 方法中参数类型 T 是 E 的子类,T 中某些操作 E 是不能满足的。

// java/util/List.class
public interface List<E> extends Collection<E> {......boolean addAll(Collection<? extends E> c);
}

addAll 会把参数 Collection<? extends E> c 中的所有元素以其迭代器返回顺序添加到该 List 末尾。

Appends all of the elements in the specified collection to the end of this list, in the order that they are returned by the specified collection’s iterator (optional operation). The behavior of this operation is undefined if the specified collection is modified while the operation is in progress. (Note that this will occur if the specified collection is this list, and it’s nonempty.)

对于 addAll 方法,参数 Collection<? extends E> c 是生产者,负责提供向 List<E> 末尾添加的元素。
根据PECS原则,这里应该使用 Collection<? extends E> c 而非 Collection<? super E> c ,这样可以保证从集合 c 中获取的元素都是 E 的子类,任何对 E 进行的操作它都可以满足。

http://www.hkea.cn/news/52580/

相关文章:

  • 个人博客网站如何做SEO雅诗兰黛网络营销策划书
  • 唐山自助建站软件seo软件优化工具软件
  • 推广电子商务网站的案例网站推广策划书模板
  • 前端外包网站网站优化快速排名软件
  • 凡客做网站cba最新消息
  • 郑州做网站好的公搜索引擎优化好做吗
  • 网站 预算白度
  • 中国电商建站程序信息推广
  • 网站开发教程 布局优化技术
  • 做外贸网站需要请外贸文员吗网站seo诊断分析和优化方案
  • 百度网站怎么做的赚钱吗seo中文含义
  • 做网站界面的软件互联网培训
  • 电子商务网站建设与维护李建忠高级搜索引擎技巧
  • 做地产网站全网搜索软件
  • 网站开发培训班百度网站推广关键词怎么查
  • 东莞市做网站公司seo怎样
  • ps做网站大小尺寸应用商店优化
  • 网站站群建设方案知名网页设计公司
  • 广州网站建设公司哪家好专业的seo搜索引擎优化培训
  • 外国人做汉字网站seo搜索排名影响因素主要有
  • 外贸五金网站建设网站制作优化排名
  • 义乌网站建设多少钱网络平台营销
  • 怀仁有做网站的公司吗磁力搜索引擎2023
  • 建站行业都扁平化设计合肥网站推广公司哪家好
  • 做企业网站织梦和wordpress哪个好百度指数查询工具app
  • 郑州网站服务公司优化神马排名软件
  • 茶叶网站建设的优势南宁seo外包平台
  • 高古楼网站 做窗子北京seo技术交流
  • 南阳建设网站制作网络最有效的推广方法
  • 纯静态网站seoseo排名优化北京