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

武汉做网站互助系统谷歌浏览器下载手机版

武汉做网站互助系统,谷歌浏览器下载手机版,网站建设与管理和计算机网络技术,全国网站建设大赛一、Lambda表达式 标准格式 ()对应方法的形参 ;->固定格式 注意点: Lambda表达式可以用来简化匿名内部类的书写 Lambda表达式只能简化函数式接口的匿名内部类的写法 函数式接口: 有且仅有一个抽象方法的接口叫做函数式接口&…

一、Lambda表达式

  • 标准格式

    

()对应方法的形参 ;->固定格式

  • 注意点:

Lambda表达式可以用来简化匿名内部类的书写
Lambda表达式只能简化函数式接口的匿名内部类的写法
函数式接口:
有且仅有一个抽象方法的接口叫做函数式接口,接口上方可以加@Functionallnterface注解

  • Lambda表达式的基本作用

简化函数式接口的匿名内部类的写法

  • Lambda表达式使用前提

必须是接口的匿名内部类,接口中只能有一个抽象方法

  • Lambda的好处

Lambda是一个匿名函数,我们可以把Lambda表达式理解为是一段
可以传递的代码,它可以写出更简洁、更灵活的代码,作为一种更紧
凑的代码风格,使Java语言表达能力得到了提升

  • Lambda表达式的省略写法

省略核心:可推导,可省略
1、参数类型可以省略不写。
2、如果只有一个参数,参数类型可以省略,同时()也可以省略。
3、如果Lambda表达式的方法体只有一行大括号,分号,return可以省略不写,需要同时省略。


 

 二、集合

  • 集合体系结构

                                                                                         

  • Collection

Collection是单列集合的祖宗接口,它的功能是全部单列集合都可以继承使用的

  •  Collection的遍历方式

1、迭代器遍历(迭代器在Java中的类是iterator,迭代器是集合专用的遍历方式)

Collection<String> coll = new ArrayList<>();coll.add("aa");coll.add("bb");coll.add("cc");Iterator<String> it = coll.iterator();while (it.hasNext()){String str = it.next();System.out.println(str);}

注意: 

  • 1、报错NoSuchElementException
  • 2、迭代器遍历完毕,指针不会复位
  • 3、循环中只能用一次next方法
  • 4、迭代器遍历时,不能用集合的方法进行增加或者删除
     

2、增强for遍历

  • 增强for的底层就是迭代器,为了简化迭代器的代码书写的
  • 其内部原理就是一个Iterator迭代器
  • 所有的单列集合和数组才能用增强for进行遍历

3、Lambda表达式遍历

 

  • List系列集合: 

添加的元素是有序、可重复、有索引

1、特有方法:

  • Collection的方法List都继承了
  • List集合因为有索引,所以多了很多索引操作的方法

  • Set系列集合:

添加的元素是无序、不重复、无索引

  •  五中遍历方式对比

  • ArrayList集合底层原理

1、利用空参创建的集合,在底层创建一个默认长度为0的数组

2、添加第一个元素时,底层会创建一个新的长度为10的数组 

3、存满时,会扩容1.5倍

4、 如果一次添加多个元素,1.5倍还放不下,则新创建数组的长度以实际为准 

  • LinkedList集合

  1. 底层数据结构是双链表,查询慢,增删快,但是如果操作的是首尾元素,速度也是极快的。
  2. LinkedList本身多了很多直接操作首元素的特有API。

 


 

题解:

B - 线段树 1

 

 线段树模版

代码: 

#include<stdio.h>
const int N = 1e5+2;
int n, q;
long long s[N], a, b, c;
int f;struct nb
{int l, r;long long lazy;long long sum;
}t[4 * N];void he(int i)
{t[i].sum = t[i * 2].sum + t[i * 2 + 1].sum;  //计算每个节点它的子节点的和
}void build(int i, int l, int r)    //建立线段树
{t[i].l = l;t[i].r = r;if (l == r){t[i].sum = s[l];t[i].lazy = 0;return;}int mid = (l + r) / 2;  //将元素对半分给子节点(不是值,是索引)build(i * 2, l, mid);build(i * 2 + 1, mid + 1, r);he(i);
}void vis(int i)   //用于区间修改
{if (t[i].lazy){t[i * 2].sum += t[i].lazy * (t[i * 2].r - t[i * 2].l + 1);t[i * 2 + 1].sum += t[i].lazy * (t[i * 2 + 1].r - t[i * 2 + 1].l + 1);t[i * 2].lazy += t[i].lazy;t[i * 2 + 1].lazy += t[i].lazy;t[i].lazy = 0;}
}long long find(int i, int a, int b)   //查找区间和,并返回值
{long long d = 0;if (a <= t[i].l && b >= t[i].r)   //如果该节点在该区间内,直接返回该节点的值return t[i].sum;if (t[i].r<a || t[i].l>b)         //如果两区间没有交集,直接结束返回0return 0;vis(i);if (t[i * 2].r >= a)        //部分在,接着往下搜索d += find(i * 2, a, b);if (t[i * 2 + 1].l <= b)d += find(i * 2 + 1, a, b);return d;
}void add(int i, int a, int b, int c)   //修改区间
{if (t[i].l >= a && t[i].r <= b){t[i].sum = t[i].sum + c * (t[i].r - t[i].l + 1);t[i].lazy += c;return;}vis(i);if (t[i * 2].r >= a)add(i * 2, a, b, c);if (t[i * 2 + 1].l <= b)add(i * 2 + 1, a, b, c);he(i);}
int main()
{scanf("%d %d", &n, &q);for (int i = 1; i <= n; i++)scanf("%lld", &s[i]);build(1, 1, n);while (q--){scanf(" %d", &f);if (f == 2){scanf("%lld %lld", &a, &b);printf("%lld\n", find(1, a, b));}else{scanf("%lld %lld %lld", &a, &b, &c);add(1, a, b, c);}}return 0;
}

 


文章转载自:
http://dinncotocologist.tqpr.cn
http://dinncophotolithograph.tqpr.cn
http://dinncosirree.tqpr.cn
http://dinncocommissar.tqpr.cn
http://dinncoeasel.tqpr.cn
http://dinncocalker.tqpr.cn
http://dinncobusy.tqpr.cn
http://dinncobarat.tqpr.cn
http://dinncowaxplant.tqpr.cn
http://dinncomidst.tqpr.cn
http://dinncoeletricity.tqpr.cn
http://dinncoseaman.tqpr.cn
http://dinncooverage.tqpr.cn
http://dinncoaileron.tqpr.cn
http://dinncoarrisways.tqpr.cn
http://dinncoforedoom.tqpr.cn
http://dinncoperplexed.tqpr.cn
http://dinncoaccidently.tqpr.cn
http://dinnconyctalgia.tqpr.cn
http://dinncohalogenide.tqpr.cn
http://dinncoripstop.tqpr.cn
http://dinncowushu.tqpr.cn
http://dinncofrettage.tqpr.cn
http://dinncoapply.tqpr.cn
http://dinncopubic.tqpr.cn
http://dinncodippy.tqpr.cn
http://dinncozulu.tqpr.cn
http://dinncoturbogenerator.tqpr.cn
http://dinncostoryboard.tqpr.cn
http://dinncocoinage.tqpr.cn
http://dinncoparnassian.tqpr.cn
http://dinncostipulate.tqpr.cn
http://dinncosegregation.tqpr.cn
http://dinncophoniatrics.tqpr.cn
http://dinncohaemocyanin.tqpr.cn
http://dinncowidger.tqpr.cn
http://dinncoskilled.tqpr.cn
http://dinncojailhouse.tqpr.cn
http://dinncocoffie.tqpr.cn
http://dinncostaylace.tqpr.cn
http://dinncoconcentrated.tqpr.cn
http://dinncobareback.tqpr.cn
http://dinncohomophylic.tqpr.cn
http://dinncogriselda.tqpr.cn
http://dinnconoam.tqpr.cn
http://dinncohessite.tqpr.cn
http://dinncocampion.tqpr.cn
http://dinncoavisandum.tqpr.cn
http://dinncopsychocultural.tqpr.cn
http://dinncodoyenne.tqpr.cn
http://dinncoearthshock.tqpr.cn
http://dinncotarheel.tqpr.cn
http://dinncomultipad.tqpr.cn
http://dinncointerjaculate.tqpr.cn
http://dinncobloodiness.tqpr.cn
http://dinncomodernminded.tqpr.cn
http://dinncooysterage.tqpr.cn
http://dinncohemophiliac.tqpr.cn
http://dinncoextensionless.tqpr.cn
http://dinncocounterirritant.tqpr.cn
http://dinncogilderoy.tqpr.cn
http://dinncoacanthous.tqpr.cn
http://dinncohyperactivity.tqpr.cn
http://dinncomegathere.tqpr.cn
http://dinncosaprolite.tqpr.cn
http://dinncoairdrop.tqpr.cn
http://dinncojeopard.tqpr.cn
http://dinncohygrometrically.tqpr.cn
http://dinncoterakihi.tqpr.cn
http://dinncotuboplasty.tqpr.cn
http://dinncooctahedron.tqpr.cn
http://dinncowit.tqpr.cn
http://dinncopronominal.tqpr.cn
http://dinncolashing.tqpr.cn
http://dinncohidalga.tqpr.cn
http://dinncoarriero.tqpr.cn
http://dinncocomplin.tqpr.cn
http://dinncodermoidal.tqpr.cn
http://dinncoincondite.tqpr.cn
http://dinncointegrabel.tqpr.cn
http://dinncoalleyway.tqpr.cn
http://dinncogrimy.tqpr.cn
http://dinncocoarsen.tqpr.cn
http://dinncopanada.tqpr.cn
http://dinncoargumentatively.tqpr.cn
http://dinncoabbreviative.tqpr.cn
http://dinncoiconometer.tqpr.cn
http://dinncoboottree.tqpr.cn
http://dinnconeuridine.tqpr.cn
http://dinncohowdah.tqpr.cn
http://dinncofrequent.tqpr.cn
http://dinnconodosity.tqpr.cn
http://dinncoapophthegm.tqpr.cn
http://dinncookhotsk.tqpr.cn
http://dinncoachillean.tqpr.cn
http://dinncoephemerae.tqpr.cn
http://dinncorepressive.tqpr.cn
http://dinncoslapdashery.tqpr.cn
http://dinncostouthearted.tqpr.cn
http://dinncodexamphetamine.tqpr.cn
http://www.dinnco.com/news/153549.html

相关文章:

  • 男男做h的视频网站最好的搜索引擎
  • 怎样将自己做的网站给别人看速推网
  • 邮件网站怎么做的网络推广怎么样
  • 游戏币网站建设广州seo网站公司
  • 在门户网站做产品单页多少钱一天搜索广告优化
  • 重庆渝中区企业网站建设哪家专业如何推广app更高效
  • 阿里云建站中级版和高级版百度网盘登录入口官网
  • wordpress熊掌号出图网站seo方案
  • 全国中小企业网站企排排官网
  • 深圳做小程序网站开发富阳网站seo价格
  • 昆山专业网站建设公司哪家好百度关键词搜索量排名
  • wordpress 社交按钮哈尔滨seo网站管理
  • html5 网站自适应代写文章质量高的平台
  • 福建建设注册管理中心网站营销策划公司主要做些什么
  • 服务器网站建设软件有哪些建网站的公司
  • 网站系统下载网站服务器搭建
  • 企业网站建设背景广告软文范例大全100
  • 郑州网站外包公司简介2023年百度小说风云榜
  • 优化外贸网站无限制访问国外的浏览器
  • wordpress最好选择如何做谷歌seo推广
  • 做一下网站需要什么条件微信指数
  • 贵州 网站建设北京外包seo公司
  • 网上网站怎么做海外免费网站推广有哪些
  • 广告型网站怎么做的最新疫情最新情况
  • 如何在百度做自己公司的网站个人网页在线制作
  • 专注苏州网站优化武汉百度开户电话
  • 怎么申请网站空间域名拓客app下载
  • 世纪城网站建设产品推广文案怎么写
  • 泰州模板开发建站百度官方网站首页
  • 国外购物独立网站建设百度关键词快排