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

企业官网用什么cms系统关键词优化一年多少钱

企业官网用什么cms系统,关键词优化一年多少钱,安徽网新科技有限公司,建设银行的官方网站文章目录 前言正文数据对象1. 对象整体去重2. 单个属性去重(只返回属性)3. 单个属性去重4. 多个属性去重验证方法运行结果 结尾 前言 对于list集合进行去重操作,多种情况进行记录. 只记录在学习与实践过程中需要对集合操作的场景,方便下次能够直接快速的回忆起来. 当然这些方…

文章目录

      • 前言
      • 正文
        • 数据对象
        • 1. 对象整体去重
        • 2. 单个属性去重(只返回属性)
        • 3. 单个属性去重
        • 4. 多个属性去重
        • 验证方法
        • 运行结果
      • 结尾

前言

对于list集合进行去重操作,多种情况进行记录.

只记录在学习与实践过程中需要对集合操作的场景,方便下次能够直接快速的回忆起来.

当然这些方法的使用与操作皆是对于Java8stream操作,TreeSet不重复特性进行的运用.

如果能够更好更快的达成目的,也是不必拘泥于某一些固定的方式去处理数据,以效率与程序开销优先.

正文

数据对象

将数据对象写成静态不可变的list来方便我们对于程序进行调用验证

private static final List<SyncBalance> list = asList(new SyncBalance(BigDecimal.ZERO, "12345678", 0, 1, "GGBond", 32, 0),new SyncBalance(BigDecimal.ZERO, "22345678", 0, 1, "GGBond", 32, 0),new SyncBalance(BigDecimal.ZERO, "22345678", 1, 1, "GGBond", 32, 0),new SyncBalance(BigDecimal.ZERO, "22345678", 1, 1, "GGBond", 32, 0)
);
1. 对象整体去重
/*** 1. 对所有属性一样的数据进行去重*/
public static void allColumnDistinct() {List<SyncBalance> allColumnDistinct = list.stream().distinct().collect(Collectors.toList());
}
2. 单个属性去重(只返回属性)
/*** 2. 对单个属性去重,只返回去重的属性*/
public static void columnDistinct() {List<String> columnDistinct = list.stream().map(SyncBalance::getMobile).distinct().collect(Collectors.toList());
}
3. 单个属性去重
/*** 3-1. 对单个属性一样的数据进行去重,下面是对`mobile`去重*/
public static void oneColumnDistinctMethodOne() {List<SyncBalance> oneColumnDistinctMethodOne = list.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(SyncBalance::getMobile))), ArrayList::new));
}
/*** 3-2. 对单个属性一样的数据进行去重,下面是对`mobile`去重(通过自定义属性去重方法)*/
public static void oneColumnDistinctMethodTwo() {List<SyncBalance> oneColumnDistinctMethodTwo = list.stream().filter(distinctByKey(i -> i.getMobile())).collect(Collectors.toList());
}/**
* list对象单个个字段去重(自定义属性)
* @param keyExtractor 去重的对象字段
* @return
* @param <T>
*/
public static <T> Predicate<T> distinctByKey(Function<? super T, ?> keyExtractor) {Map<Object, Boolean> seen = new ConcurrentHashMap<>();return t -> seen.putIfAbsent(keyExtractor.apply(t), Boolean.TRUE) == null;
}
/*** 3-3. 对单个属性一样的数据进行去重,下面是对`mobile`去重* 利用TreeSet进行去重*/
public static void oneColumnDistinctMethodThree() {TreeSet<SyncBalance> oneColumnDistinctMethodThree = new TreeSet<>(Comparator.comparing(i -> i.getMobile()));list.forEach(a -> oneColumnDistinctMethodThree.add(a));
}
4. 多个属性去重
/*** 4. 多个字段条件去重*/
public static void twoColumnDistinct() {List<SyncBalance> twoColumnDistinct = list.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(p -> p.getMobile() + ";" + p.getStatus()))), ArrayList::new));
}
验证方法

对于验证方法添加了一些分隔的数据

/*** 验证的main方法* @param args*/
public static void main(String[] args) {allColumnDistinct();columnDistinct();oneColumnDistinctMethodOne();oneColumnDistinctMethodTwo();oneColumnDistinctMethodThree();twoColumnDistinct();
}
运行结果
allColumnDistinct---v
SyncBalance(accountBalance=0, mobile=12345678, status=0, sysId=1, loginAccountName=GGBond, keepOrUpdate=32, id=0)
SyncBalance(accountBalance=0, mobile=22345678, status=0, sysId=1, loginAccountName=GGBond, keepOrUpdate=32, id=0)
SyncBalance(accountBalance=0, mobile=22345678, status=1, sysId=1, loginAccountName=GGBond, keepOrUpdate=32, id=0)
allColumnDistinct---^
columnDistinct---v
12345678
22345678
columnDistinct---^
oneColumnDistinctMethodOne---v
SyncBalance(accountBalance=0, mobile=12345678, status=0, sysId=1, loginAccountName=GGBond, keepOrUpdate=32, id=0)
SyncBalance(accountBalance=0, mobile=22345678, status=0, sysId=1, loginAccountName=GGBond, keepOrUpdate=32, id=0)
oneColumnDistinctMethodOne---^
oneColumnDistinctMethodTwo---v
SyncBalance(accountBalance=0, mobile=12345678, status=0, sysId=1, loginAccountName=GGBond, keepOrUpdate=32, id=0)
SyncBalance(accountBalance=0, mobile=22345678, status=0, sysId=1, loginAccountName=GGBond, keepOrUpdate=32, id=0)
oneColumnDistinctMethodTwo---^
oneColumnDistinctMethodThree---v
SyncBalance(accountBalance=0, mobile=12345678, status=0, sysId=1, loginAccountName=GGBond, keepOrUpdate=32, id=0)
SyncBalance(accountBalance=0, mobile=22345678, status=0, sysId=1, loginAccountName=GGBond, keepOrUpdate=32, id=0)
oneColumnDistinctMethodThree---^
twoColumnDistinct---v
SyncBalance(accountBalance=0, mobile=12345678, status=0, sysId=1, loginAccountName=GGBond, keepOrUpdate=32, id=0)
SyncBalance(accountBalance=0, mobile=22345678, status=0, sysId=1, loginAccountName=GGBond, keepOrUpdate=32, id=0)
SyncBalance(accountBalance=0, mobile=22345678, status=1, sysId=1, loginAccountName=GGBond, keepOrUpdate=32, id=0)
twoColumnDistinct---^

image-20240518151444939

结尾

集合的操作不止拘泥于stream流TreeSet可以处理,其他一下如果可以实现皆可使用.

以上,皆可直接使用.

http://www.dtcms.com/wzjs/133965.html

相关文章:

  • 有关网站建设的参考文献搜索优化指的是什么
  • 网站建设人才便民信息微信平台推广
  • 做本地网站需要什么资质推广文案怎么写
  • 有没有免费的商城小程序哈尔滨网络优化公司有哪些
  • 天猫网站设计分析做网站哪个平台好
  • 易企秀h5制作教程推推蛙贴吧优化
  • 2007年怎么做网站南京seo整站优化技术
  • 做淘宝优惠券网站要多少钱深圳网站优化平台
  • 百度新闻网站模板百度搜索推广技巧
  • 湘潭网站建设导航网站怎么推广
  • 自己做商品网站怎么做广州今天新闻
  • 项目案例 化妆品网站上海短视频培训机构
  • java 做直播网站有哪些软件有哪些关键词长尾词优化
  • 微信营销网站模板如何软件网站优化公司
  • dedecms 我的网站刷赞网站推广ks
  • 对电子商务网站建设与管理的理解百度搜索引擎官网入口
  • 服务网站建设企业济南seo网络优化公司
  • 微名片网站怎么做上海市人大常委会
  • 中原区快速建站公司电话搜索关键词软件
  • 广东外贸网站推广公司seo 网站推广
  • 南京做网站优化公司网站优化排名软件网
  • 可信网站验证服务上海推广网站
  • WordPress网站仿制培训课程总结
  • 做网站和域名北京网络营销推广
  • 小学生网上学做辅导哪个网站好查询关键词
  • 济南网站建设泰观网络企业营销策划及推广
  • 网站基础内容磁力搜索引擎
  • 如何选择邯郸网站建设一媒体app软件下载老版本
  • reactjs 做网站宝鸡seo培训
  • 山东泰安人才网惠州seo优化服务