一、Collector的引入      

1)Collector的聚合作用前面已经使用过,将list.stream后的一系列操作之后再返回list。

2)Collector的引入,通过需求:将绿色的Apple放在一个list,黄色的Apple放在一个list

代码例子:

 package com.cy.java8;

 import java.util.*;
import java.util.stream.Collectors; public class CollectorIntroduce { public static void main(String[] args) {
List<Apple> list = Arrays.asList(new Apple("green", 150),
new Apple("yellow", 120),
new Apple("green", 170),
new Apple("green", 150),
new Apple("yellow", 120),
new Apple("green", 170) ); //Collector的聚合作用
List<Apple> greenList = list.stream().filter(a -> a.getColor().equals("green")).collect(Collectors.toList());
System.out.println(greenList); Map<String, List<Apple>> result1 = groupByNormal(list);
System.out.println(result1); Map<String, List<Apple>> result2 = groupByFunction(list);
System.out.println(result2); //Collector的groupBy
Map<String, List<Apple>> result3 = groupByCollector(list);
System.out.println(result3);
} /**
* 需求:将绿色的放在一个list,黄色的放在一个list
* 以前的写法
*/
private static Map<String, List<Apple>> groupByNormal(List<Apple> apples){
Map<String, List<Apple>> map = new HashMap<>(); for(Apple a : apples){
List<Apple> list = map.get(a.getColor());
if(list == null){
list = new ArrayList<>();
map.put(a.getColor(), list);
}
list.add(a);
} return map;
} /**
* 需求:将绿色的放在一个list,黄色的放在一个list
* 使用FunctionInterface的方法
* 虽然去掉了判断null的操作,但是也还是非常啰嗦,不够精简
*/
private static Map<String, List<Apple>> groupByFunction(List<Apple> apples){
Map<String, List<Apple>> map = new HashMap<>(); apples.stream().forEach(a -> {
List<Apple> colorList = Optional.ofNullable(map.get(a.getColor())).orElseGet(() -> {
List<Apple> list = new ArrayList<>();
map.put(a.getColor(), list);
return list;
});
colorList.add(a);
}); return map;
} /**
* 需求:将绿色的放在一个list,黄色的放在一个list
* 使用Collector
*/
private static Map<String, List<Apple>> groupByCollector(List<Apple> apples){
return apples.stream().collect(Collectors.groupingBy(Apple::getColor));
}
}

打印结果:

[Apple(color=green, weight=150), Apple(color=green, weight=170), Apple(color=green, weight=150), Apple(color=green, weight=170)]
{green=[Apple(color=green, weight=150), Apple(color=green, weight=170), Apple(color=green, weight=150), Apple(color=green, weight=170)], yellow=[Apple(color=yellow, weight=120), Apple(color=yellow, weight=120)]}
{green=[Apple(color=green, weight=150), Apple(color=green, weight=170), Apple(color=green, weight=150), Apple(color=green, weight=170)], yellow=[Apple(color=yellow, weight=120), Apple(color=yellow, weight=120)]}
{green=[Apple(color=green, weight=150), Apple(color=green, weight=170), Apple(color=green, weight=150), Apple(color=green, weight=170)], yellow=[Apple(color=yellow, weight=120), Apple(color=yellow, weight=120)]}

二、Collectors的API介绍和使用  

averagingDouble;

averagingInt;

averagingLong;

collectingAndThen;

counting;

groupingBy;

summarizingInt;

代码例子:

 package com.cy.java8;

 import java.util.*;
import java.util.stream.Collectors; public class CollectorsAction {
private final static List<Dish> menu = Arrays.asList(
new Dish("pork", false, 800, Dish.Type.MEAT),
new Dish("beef", false, 700, Dish.Type.MEAT),
new Dish("chicken", false, 400, Dish.Type.MEAT),
new Dish("french fries", true, 530, Dish.Type.OTHER),
new Dish("rice", true, 350, Dish.Type.OTHER),
new Dish("season fruit", true, 120, Dish.Type.OTHER),
new Dish("pizza", true, 550, Dish.Type.OTHER),
new Dish("prawns", false, 300, Dish.Type.FISH),
new Dish("salmon", false, 450, Dish.Type.FISH)); public static void main(String[] args) {
testAveragingDouble();
testAveragingInt();
testCollectingAndThen();
testCounting();
testGroupingByFunction();
testGroupingByFunctionAndCollector();
testGroupingByFunctionAndSupplierAndCollector();
testSummarizingInt();
} /**
* 计算menu中食物们卡路里的平均数
*/
private static void testAveragingDouble(){
System.out.println("testAveragingDouble");
Optional.ofNullable(menu.stream().collect(Collectors.averagingDouble(Dish::getCalories)))
.ifPresent(System.out::println);
} /**
* testAveragingInt和testAveragingLong的返回值类型也是Double,和上面类似
*/
private static void testAveragingInt(){
System.out.println("testAveragingInt");
Optional.ofNullable(menu.stream().collect(Collectors.averagingInt(Dish::getCalories)))
.ifPresent(System.out::println);
} private static void testCollectingAndThen(){
System.out.println("testCollectingAndThen");
Optional.ofNullable(menu.stream().collect(Collectors.collectingAndThen(Collectors.averagingInt(Dish::getCalories), v-> "The Average Calories is " + v)))
.ifPresent(System.out::println); } /**
* 计算list<Dish>的count
*/
private static void testCounting(){
System.out.println("testCounting");
Long count = menu.stream().collect(Collectors.counting());
System.out.println(count);
} /**
* 将menu按照type类型分组
*/
private static void testGroupingByFunction(){
System.out.println("testGroupingByFunction");
Map<Dish.Type, List<Dish>> map = menu.stream().collect(Collectors.groupingBy(dish -> dish.getType()));
System.out.println(map);
} /**
* 将menu按照type分组,并计算每个组元素数量
*/
private static void testGroupingByFunctionAndCollector(){
System.out.println("testGroupingByFunctionAndCollector");
Map<Dish.Type, Long> map1 = menu.stream().collect(Collectors.groupingBy(dish -> dish.getType(), Collectors.counting()));
System.out.println(map1); //每个类型卡路里的平均值
Map<Dish.Type, Double> map2 = menu.stream().collect(Collectors.groupingBy(dish -> dish.getType(), Collectors.averagingInt(Dish::getCalories)));
System.out.println(map2);
} /**
* Supplier mapFactory,第2个参数,可以指定传入什么类型的map
*/
private static void testGroupingByFunctionAndSupplierAndCollector(){
System.out.println("testGroupingByFunctionAndSupplierAndCollector");
Map<Dish.Type, Double> map = menu.stream().collect(Collectors.groupingBy(Dish::getType, TreeMap::new, Collectors.averagingInt(Dish::getCalories)));
System.out.println(map.getClass());
System.out.println(map);
} /**
* 将菜单menu按照卡路里进行汇总
*/
private static void testSummarizingInt(){
System.out.println("testSummarizingInt");
IntSummaryStatistics result = menu.stream().collect(Collectors.summarizingInt(Dish::getCalories));
System.out.println(result);
}
}

打印结果:

testAveragingDouble
466.6666666666667
testAveragingInt
466.6666666666667
testCollectingAndThen
The Average Calories is 466.6666666666667
testCounting
9
testGroupingByFunction
{MEAT=[Dish{name='pork', vegetarian=false, calories=800, type=MEAT}, Dish{name='beef', vegetarian=false, calories=700, type=MEAT}, Dish{name='chicken', vegetarian=false, calories=400, type=MEAT}], OTHER=[Dish{name='french fries', vegetarian=true, calories=530, type=OTHER}, Dish{name='rice', vegetarian=true, calories=350, type=OTHER}, Dish{name='season fruit', vegetarian=true, calories=120, type=OTHER}, Dish{name='pizza', vegetarian=true, calories=550, type=OTHER}], FISH=[Dish{name='prawns', vegetarian=false, calories=300, type=FISH}, Dish{name='salmon', vegetarian=false, calories=450, type=FISH}]}
testGroupingByFunctionAndCollector
{MEAT=3, OTHER=4, FISH=2}
{MEAT=633.3333333333334, OTHER=387.5, FISH=375.0}
testGroupingByFunctionAndSupplierAndCollector
class java.util.TreeMap
{MEAT=633.3333333333334, FISH=375.0, OTHER=387.5}
testSummarizingInt
IntSummaryStatistics{count=9, sum=4200, min=120, average=466.666667, max=800}

三、Collectors的API介绍和使用2  

GroupingByConcurrent;

joining;

mapping;

maxBy

代码举例如下:

 package com.cy.java8;

 import java.util.Comparator;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ConcurrentSkipListMap;
import java.util.stream.Collectors;
import static com.cy.java8.CollectorsAction.menu; public class CollectorsAction2 { public static void main(String[] args) {
testGroupingByConcurrentWithFunction();
testGroupingByConcurrentWithFunctionAndCollector();
testGroupingByConcurrentWithFunctionAndSupplierAndCollector();
testJoining();
testMapping();
testMaxBy();
} /**
* 按食物类型分类
*/
private static void testGroupingByConcurrentWithFunction() {
System.out.println("testGroupingByConcurrentWithFunction");
ConcurrentMap<Dish.Type, List<Dish>> map = menu.stream().collect(Collectors.groupingByConcurrent(Dish::getType));
System.out.println(map.getClass());
System.out.println(map);
} /**
* 每类食物类型下面 卡路里平均值
*/
private static void testGroupingByConcurrentWithFunctionAndCollector() {
System.out.println("testGroupingByConcurrentWithFunctionAndCollector");
ConcurrentMap<Dish.Type, Double> map = menu.stream().collect(Collectors.groupingByConcurrent(Dish::getType, Collectors.averagingInt(Dish::getCalories)));
System.out.println(map);
} private static void testGroupingByConcurrentWithFunctionAndSupplierAndCollector() {
System.out.println("testGroupingByConcurrentWithFunctionAndCollector");
ConcurrentMap<Dish.Type, Double> map = menu.stream().collect(Collectors.groupingByConcurrent(Dish::getType, ConcurrentSkipListMap::new, Collectors.averagingInt(Dish::getCalories)));
System.out.println(map.getClass());
System.out.println(map);
} /**
* joining: 对stream里面的一些值进行连接
* 对食物的名字进行连接
*/
private static void testJoining() {
System.out.println("testJoining");
String s = menu.stream().map(Dish::getName).collect(Collectors.joining(",", "Names[", "]"));
System.out.println(s);
} /**
* 用一个mapping function在汇聚之前,将接受Dish的集合适用于接受DishName的集合
*/
private static void testMapping() {
System.out.println("testMapping");
String s = menu.stream().collect(Collectors.mapping(d -> d.getName(), Collectors.joining(",", "Names[", "]")));
System.out.println(s);
} /**
* 找出热量最大的食物
*/
private static void testMaxBy(){
System.out.println("testMaxBy");
Optional<Dish> maxCaloriesOptional = menu.stream().collect(Collectors.maxBy(Comparator.comparingInt(Dish::getCalories)));
maxCaloriesOptional.ifPresent(System.out::println);
} }

打印结果:

testGroupingByConcurrentWithFunction
class java.util.concurrent.ConcurrentHashMap
{FISH=[Dish{name='prawns', vegetarian=false, calories=300, type=FISH}, Dish{name='salmon', vegetarian=false, calories=450, type=FISH}], MEAT=[Dish{name='pork', vegetarian=false, calories=800, type=MEAT}, Dish{name='beef', vegetarian=false, calories=700, type=MEAT}, Dish{name='chicken', vegetarian=false, calories=400, type=MEAT}], OTHER=[Dish{name='french fries', vegetarian=true, calories=530, type=OTHER}, Dish{name='rice', vegetarian=true, calories=350, type=OTHER}, Dish{name='season fruit', vegetarian=true, calories=120, type=OTHER}, Dish{name='pizza', vegetarian=true, calories=550, type=OTHER}]}
testGroupingByConcurrentWithFunctionAndCollector
{FISH=375.0, MEAT=633.3333333333334, OTHER=387.5}
testGroupingByConcurrentWithFunctionAndCollector
class java.util.concurrent.ConcurrentSkipListMap
{MEAT=633.3333333333334, FISH=375.0, OTHER=387.5}
testJoining
Names[pork,beef,chicken,french fries,rice,season fruit,pizza,prawns,salmon]
testMapping
Names[pork,beef,chicken,french fries,rice,season fruit,pizza,prawns,salmon]
testMaxBy
Dish{name='pork', vegetarian=false, calories=800, type=MEAT}

四、Collectors的API介绍和使用3

partitioningBy

reduce

summarizingDouble

summarizingLong

summarizingInt

代码举例如下:

 package com.cy.java8;

 import java.util.*;
import java.util.function.BinaryOperator;
import java.util.stream.Collectors; import static com.cy.java8.CollectorsAction.menu; public class CollectorsAction3 { public static void main(String[] args) {
testPartitioningByWithPredicate();
testPartitioningByWithPredicateAndCollector();
testReducingBinaryOperator();
testReducingBinaryOperatorAndIdentity();
testReducingBinaryOperatorAndIdentityAndFunction();
testSummarizingDouble();
testSummarizingLong();
testSummarizingInt();
} /**
* 利用partitioningBy把menu中素食类和非素食类的分开
*/
private static void testPartitioningByWithPredicate() {
System.out.println("testPartitioningByPredicate");
Map<Boolean, List<Dish>> map = menu.stream().collect(Collectors.partitioningBy(Dish::isVegetarian));
System.out.println(map);
} /**
* 把素食类和非素食类分开,计算平均卡路里
*/
private static void testPartitioningByWithPredicateAndCollector() {
System.out.println("testPartitioningByWithPredicateAndCollector");
Map<Boolean, Double> map = menu.stream().collect(Collectors.partitioningBy(Dish::isVegetarian, Collectors.averagingInt(Dish::getCalories)));
System.out.println(map);
System.out.println(map.get(true));
} /**
* 找出menu中热量最大的dish
*/
private static void testReducingBinaryOperator() {
System.out.println("testReducingBinaryOperator");
//以前这么写
Optional<Dish> optional = menu.stream().reduce((dish1, dish2) -> dish1.getCalories() > dish2.getCalories() ? dish1 : dish2);
optional.ifPresent(System.out::println); //Collectors.reducing
Optional<Dish> optional2 = menu.stream().collect(Collectors.reducing(BinaryOperator.maxBy(Comparator.comparingInt(Dish::getCalories))));
optional2.ifPresent(System.out::println); Optional<Dish> optional3 = menu.stream().collect(Collectors.reducing((dish1, dish2) -> dish1.getCalories() > dish2.getCalories() ? dish1 : dish2));
optional3.ifPresent(System.out::println);
} /**
* 计算所有卡路里和
*/
private static void testReducingBinaryOperatorAndIdentity() {
System.out.println("testReducingBinaryOperatorAndIdentity");
//以前这么写
Integer totalCalories1 = menu.stream().map(Dish::getCalories).reduce(0, Integer::sum);
System.out.println(totalCalories1); //Collectors.reducing
Integer totalCalories2 = menu.stream().map(Dish::getCalories).collect(Collectors.reducing(0, Integer::sum));
System.out.println(totalCalories2);
} private static void testReducingBinaryOperatorAndIdentityAndFunction() {
System.out.println("testReducingBinaryOperatorAndIdentityAndFunction");
Integer result = menu.stream().collect(Collectors.reducing(0, Dish::getCalories, (d1, d2) -> d1 + d2));
System.out.println(result);
} private static void testSummarizingDouble(){
System.out.println("testSummarizingDouble");
DoubleSummaryStatistics result = menu.stream().collect(Collectors.summarizingDouble(Dish::getCalories));
System.out.println(result);
} private static void testSummarizingLong(){
System.out.println("testSummarizingLong");
LongSummaryStatistics result = menu.stream().collect(Collectors.summarizingLong(Dish::getCalories));
System.out.println(result);
} private static void testSummarizingInt(){
System.out.println("testSummarizingInt");
IntSummaryStatistics result = menu.stream().collect(Collectors.summarizingInt(Dish::getCalories));
System.out.println(result);
}
}

打印结果:

testPartitioningByPredicate
{false=[Dish{name='pork', vegetarian=false, calories=800, type=MEAT}, Dish{name='beef', vegetarian=false, calories=700, type=MEAT}, Dish{name='chicken', vegetarian=false, calories=400, type=MEAT}, Dish{name='prawns', vegetarian=false, calories=300, type=FISH}, Dish{name='salmon', vegetarian=false, calories=450, type=FISH}], true=[Dish{name='french fries', vegetarian=true, calories=530, type=OTHER}, Dish{name='rice', vegetarian=true, calories=350, type=OTHER}, Dish{name='season fruit', vegetarian=true, calories=120, type=OTHER}, Dish{name='pizza', vegetarian=true, calories=550, type=OTHER}]}
testPartitioningByWithPredicateAndCollector
{false=530.0, true=387.5}
387.5
testReducingBinaryOperator
Dish{name='pork', vegetarian=false, calories=800, type=MEAT}
Dish{name='pork', vegetarian=false, calories=800, type=MEAT}
Dish{name='pork', vegetarian=false, calories=800, type=MEAT}
testReducingBinaryOperatorAndIdentity
4200
4200
testReducingBinaryOperatorAndIdentityAndFunction
4200
testSummarizingDouble
DoubleSummaryStatistics{count=9, sum=4200.000000, min=120.000000, average=466.666667, max=800.000000}
testSummarizingLong
LongSummaryStatistics{count=9, sum=4200, min=120, average=466.666667, max=800}
testSummarizingInt
IntSummaryStatistics{count=9, sum=4200, min=120, average=466.666667, max=800}

  

五、Collectors的API介绍和使用4

summingDouble

summingLong

summingInt

toCollection

toConcurrentMap

toMap

toList

toSet

代码举例如下:

 package com.cy.java8;

 import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ConcurrentSkipListMap;
import java.util.stream.Collectors;
import static com.cy.java8.CollectorsAction.menu; public class CollectorsAction4 { public static void main(String[] args) {
testSummingDouble();
testToCollection();
testToConcurrentMap();
testToConcurrentMapAndBinaryOperator();
testToConcurrentMapAndBinaryOperatorAndSupplier();
testToList();
testToSet();
} /**
* 计算卡路里总和
*/
private static void testSummingDouble(){
System.out.println("testSummingDouble--------------");
//以前的写法
double sum = menu.stream().map(Dish::getCalories).mapToDouble(Integer::doubleValue).sum();
System.out.println(sum); //Collectors.summingDouble
Double sum2 = menu.stream().collect(Collectors.summingDouble(Dish::getCalories));
System.out.println(sum2);
} private static void testToCollection(){
System.out.println("testToCollection--------------");
LinkedList<Dish> list = menu.stream().filter(dish -> dish.getCalories() > 600).collect(Collectors.toCollection(LinkedList::new));
System.out.println(list);
} private static void testToConcurrentMap(){
System.out.println("testToConcurrentMap--------------");
ConcurrentMap<String, Integer> map = menu.stream().filter(dish -> dish.getCalories() > 600).collect(Collectors.toConcurrentMap(d -> d.getName(), d -> d.getCalories()));
System.out.println(map);
} /**
* Type : total
* 将menu转化为,key是type,value是这个type下有多少个,这样的map
*/
private static void testToConcurrentMapAndBinaryOperator(){
System.out.println("testToConcurrentMapAndBinaryOperator--------------");
ConcurrentMap<Dish.Type, Integer> map = menu.stream().collect(Collectors.toConcurrentMap(Dish::getType, d -> 1, (v1, v2) -> v1 + v2));
System.out.println(map.getClass());
System.out.println(map);
} private static void testToConcurrentMapAndBinaryOperatorAndSupplier(){
System.out.println("testToConcurrentMapAndBinaryOperatorAndSupplier--------------");
ConcurrentSkipListMap<Dish.Type, Integer> map = menu.stream().collect(Collectors.toConcurrentMap(Dish::getType, d -> 1, (v1, v2) -> v1 + v2, ConcurrentSkipListMap::new));
System.out.println(map.getClass());
System.out.println(map);
} private static void testToList() {
System.out.println("testToList--------------");
List<Dish> list = menu.stream().filter(Dish::isVegetarian).collect(Collectors.toList());
System.out.println(list.getClass());
System.out.println(list);
} /**
* 返回值类型为集合HashSet,里面的值不能重复,根据hashCode和equals做的判断
*/
private static void testToSet() {
System.out.println("testToSet--------------");
Set<Dish> set = menu.stream().filter(Dish::isVegetarian).collect(Collectors.toSet());
System.out.println(set.getClass());
System.out.println(set);
} /**
* toMap : 略
* toMap 和上面的 toConcurrentMap用法是一样的,只不过返回的是HashMap
*/
}

打印结果:

testSummingDouble--------------
4200.0
4200.0
testToCollection--------------
[Dish{name='pork', vegetarian=false, calories=800, type=MEAT}, Dish{name='beef', vegetarian=false, calories=700, type=MEAT}]
testToConcurrentMap--------------
{beef=700, pork=800}
testToConcurrentMapAndBinaryOperator--------------
class java.util.concurrent.ConcurrentHashMap
{OTHER=4, FISH=2, MEAT=3}
testToConcurrentMapAndBinaryOperatorAndSupplier--------------
class java.util.concurrent.ConcurrentSkipListMap
{MEAT=3, FISH=2, OTHER=4}
testToList--------------
class java.util.ArrayList
[Dish{name='french fries', vegetarian=true, calories=530, type=OTHER}, Dish{name='rice', vegetarian=true, calories=350, type=OTHER}, Dish{name='season fruit', vegetarian=true, calories=120, type=OTHER}, Dish{name='pizza', vegetarian=true, calories=550, type=OTHER}]
testToSet--------------
class java.util.HashSet
[Dish{name='rice', vegetarian=true, calories=350, type=OTHER}, Dish{name='pizza', vegetarian=true, calories=550, type=OTHER}, Dish{name='season fruit', vegetarian=true, calories=120, type=OTHER}, Dish{name='french fries', vegetarian=true, calories=530, type=OTHER}]

  

-----

Collector的使用的更多相关文章

  1. The The Garbage-First (G1) collector since Oracle JDK 7 update 4 and later releases

    Refer to http://www.oracle.com/technetwork/tutorials/tutorials-1876574.html for detail. 一些内容复制到这儿 Th ...

  2. hdu 2602 Bone Collector(01背包)模板

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2602 Bone Collector Time Limit: 2000/1000 MS (Java/Ot ...

  3. Jmeter plugin jp@gc - PerfMon Metrics Collector

    Jmeter由于是开源工具,所以目前有很多插件可以供使用,最简单的方法是先把Plugin Manager安装了 下载地址:https://jmeter-plugins.org/wiki/Plugins ...

  4. Spring AOP 开发中遇到问题:Caused by: java.lang.IllegalArgumentException: warning no match for this type name: com.xxx.collector.service.impl.XxxServiceImpl [Xlint:invalidAbsoluteTypeName]

    在网上找了很多,都不是我想要的,后来发现是我在springaop注解的时候 写错了类名导致的这个问题 @Pointcut("execution(* com.xxx.collector.ser ...

  5. HDU2639Bone Collector II[01背包第k优值]

    Bone Collector II Time Limit: 5000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others ...

  6. HDOJ 4336 Card Collector

    容斥原理+状压 Card Collector Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/O ...

  7. HDU 2602 Bone Collector WA谁来帮忙找找错

    Problem Description Many years ago , in Teddy’s hometown there was a man who was called “Bone Collec ...

  8. Bone Collector(01背包)

    题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=87125#problem/N 题目: Description Many year ...

  9. (三)CMS Collector

    有些资料中,为区别parallel collector ,将应用与gc并发成为并行,在接下来的文章中,仍称为并发. -XX:useConcMarkSweepGC,可以用于minor gc和major ...

  10. zabbix登陆问题:cannot allocate shared memory for collector

    问题说明:在一台zabbix被监控服务器上(64位centos6.8系统,64G内容)启动zabbix_agent,发现进程无法启动,10050端口没有起来! 启动zabbix_agent进程没有报错 ...

随机推荐

  1. 利用python自动发邮件

    工作中有时长时间运行代码时需要监控进度,或者需要定期发送固定格式邮件时,可以使用下面定义的邮件函数. 该函数调用了outlook和qqmail的接口,只需要放置到python的环境目录中即可 impo ...

  2. Laravel5学习

    [1]缓存问题 laravel中使用的配置文件,都会放在config目录下面,当变更某个参数的时候,如果发现不生效,可以在命令行下面执行  php artisan config:clear 命令才清除 ...

  3. mysql5.7.26做主主配置

    一.首先两台服务器安装好mysql数据库环境 参照linux rpm方式安装mysql5.1 https://www.cnblogs.com/sky-cheng/p/10564604.html 二.在 ...

  4. 数据可视化之颜色,线型,maker

    https://blog.csdn.net/m0_37362454/article/details/82791527 https://blog.csdn.net/qiu931110/article/d ...

  5. Java基本的程序结构设计 大数操作

    大数操作 BigInteger 不可变的任意精度的整数.所有操作中,都以二进制补码形式表示 BigInteger(如 Java 的基本整数类型).BigInteger 提供所有 Java 的基本整数操 ...

  6. 软件安装:树上分组DP/tarjan缩点/(也许基环树?)

    提炼:tarjan环缩成点,建0虚根,跑树形DP,最难的是看出可能有n个点n条边然后缩点,n个点n条边可能不只有一个环 n个点n条边->基环树: 基环树,也是环套树,简单地讲就是树上在加一条边. ...

  7. Python _easygui详细版

    1. msgbox msgbox(msg='(Your message goes here)', title=' ', ok_button='OK', image=None, root=None) m ...

  8. day_04 基本数据类型的结构和使用方法

    1. 简述Python的五大数据类型的作用.定义方式.使用方法: 1). 数字类型: 整型(int): 表示年龄.号码.级别:变量名=值,变量名=int(值):加减乘除.逻辑判断: 浮点型(float ...

  9. 好好理解一下python的函数和python的缩进

    缩进相当于其他语言的括号,括号中的语句才是一起执行的 这一个函数的功能应该是计算平均分 所以d这个dict应该是作为参数传进来的,而不是写到函数内部 正确的写法 d = { 'Adam': 95, ' ...

  10. vertica,greenplumr容器安装

    一,vertica 来源: https://github.com/sumitchawla/docker-vertica 使用方法: # To run without a persistent data ...