自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(45)
  • 收藏
  • 关注

原创 MQTT同步通信实现

mqtt是发布订阅机制,消息发送方无法立即知道消息订阅方的返回消息。在一些场景下比如我通过mqtt给某温度传感器下发命令读取该设备的温度数据这时需要同步得到温度传感器返回的数据,这就需要把异步请求转化为同步请求。下面参考https://www.cnblogs.com/goodAndyxublog/p/12393723.html所描述mq方案来实现。1.方案整体流程1.发送mqtt消息生成DefaultFuture,等待返回消息。DefaultFuture的实现原理即为dubbo中..

2021-07-24 19:54:30 7442 1

原创 jmeter使用

简单记录使用jmeter测压1.jmeter下载安装略过2启动jmeter 安装在windows系统上 2.1 apache-jmeter-5.0\bin\jmeter.bat文件双击启动(此时屏幕会出现cmd窗口正常现象)成功启动界面2.2 设置语言中文(默认英文)3使用举例  300并发测试百度3.1 添加线程组   3.1.1配置线程组参数 3...

2019-01-30 15:54:39 537

原创 leetcode: Array标签题整理

2. Add Two NumbersYou are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two nu...

2018-06-30 12:50:30 446

原创 String类学习

需求:使用toString方法时将对象数组的地址打印出来这个横简单代码如下public class info{ public static void main(String[] args) { List<info> list = new ArrayList<>(); for(int i=0;i<5;i++) { list.add(new i...

2018-06-23 14:10:36 194

原创 1-项目介绍与SSM框架搭建

一 maven工程搭建架构图:有一个maven父工程来管理公司用到的所有包pom.xml<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/...

2018-06-16 12:44:18 314

原创 leetcode 125,136,141,155

125. Valid PalindromeGiven a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.Note: For the purpose of this problem, we define empty string as valid...

2018-05-05 17:14:45 139

原创 leetcode 121,122

121. Best Time to Buy and Sell StockSay you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (i.e., buy one...

2018-05-04 21:52:33 442

原创 leetcode 110,111,112,118,119

110. Balanced Binary TreeGiven a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as:a binary tree in which the depth of the two subtrees of e...

2018-05-03 11:51:22 209

原创 leetcode 101,104,107,108

101. Symmetric TreeGiven a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree [1,2,2,3,4,4,3] is symmetric: 1 / \ 2 2 / \ / ...

2018-05-01 11:19:33 287

原创 leetcode 88,100

88. Merge Sorted ArrayGiven two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.Note:The number of elements initialized in nums1 and nums2 are m and n respectively.Yo...

2018-04-30 09:16:48 156

原创 leetcode 70,83

70. Climbing StairsExample 2:Input: 3Output: 3Explanation: There are three ways to climb to the top.1. 1 step + 1 step + 1 step2. 1 step + 2 steps3. 2 steps + 1 step斐波那契数列方法一备忘录算法 int[] map = ne...

2018-04-28 11:47:19 109

原创 leetcode66,67

66. Plus OneGiven a non-empty array of digits representing a non-negative integer, plus one to the integer.The digits are stored such that the most significant digit is at the head of the list, and ea...

2018-04-27 10:07:44 463

原创 leetcode 53,58

53. Maximum SubarrayGiven an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum.Example:Input: [-2,1,-3,4,-1,2,1,-5,4],Outp...

2018-04-26 10:17:08 126

原创 leetcode 35,38

35. Search Insert PositionGiven a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.You may assume no du...

2018-04-25 10:27:59 153

原创 leetcode 27,28

Given an array nums and a value val, remove all instances of that value in-place and return the new length.Do not allocate extra space for another array, you must do this by modifying the input array ...

2018-04-24 10:17:29 108

原创 leetcode 21,26

 Merge Two Sorted ListsMerge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.Example:Input: 1->2->4, 1->...

2018-04-23 14:04:14 117

原创 leetcode1,7,9,14,20

 Two SumGiven an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solution, and you may not use the...

2018-04-22 23:29:17 112

原创 d2-用户和组管理

文件管理:    cp,mv,rm cp  [root@izm5e5qf7n47jhwufk5eo9z ~]# cp --help         Usage: cp [OPTION]... [-T] SOURCE DEST         or:  cp [OPTION]... SOURCE... DIRECTORY         or:  cp [OPTION]... -t DIRECTOR...

2018-04-14 17:52:30 515

原创 d2-linux的文件系统

linux的文件系统/etc /user /var /root /home /dev /boot: 引导文件存放目录,内核文件(vmlinuz)引导加载器(bootloader,grub) /bin:  共所有用户使用的基本命令:不能关联到独立分区,os启动用到的程序/sbin: 管理类的基本命令:不能关联至独立分区,os启动即会用到的程序 /lib:基本库文件,以及内核模块(/lib/modul...

2018-04-13 16:24:18 169

原创 linux-d1-基础命令

CentOS 6默认启动6个虚拟终端ctrl+alt+f#:[1,6]查看当前终端设备:tty显示当前使用的shell # echo ${shell}命令提示符:prompt: # 管理员 $ 普通用户命令:    which 查看ls脚本位置[root@izm5e5qf7n47jhwufk5eo9z ~]# which lsalias ls='ls --color=auto'        /u...

2018-04-13 10:48:37 817

原创 JS-面向过程改造为面向对象

原始页面代码<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/lo

2018-04-11 21:47:11 471

原创 访问者模式(Visitor)

定义:表示一个作用于某对象结构中的各元素操作,他使你可以在不改变各元素的类的前提下定义作用于这些元素的操作。(这个模式我理解的可能还不是很到位)举个例子:有一家饭店如果老板来了就给他看账单,如果消防来了他会检查店里的安全状态,如果顾客来了会想看下菜单在不改变饭店类的前提下实现根据访问者的不同查看的内容也相应不同这就用到访问者模式    一  实现一个可以被访问的目标类他提供一个方法接受访问者,在这...

2018-03-11 20:59:44 140

原创 装饰模式(Decorator)

个人对装饰模式的简单理解:使用对象组合的方式为一个类添加功能举个例子:我想使用把一段文字输入到文件中。FileOutputStream fs = new FileOutputStream("src/Decoratorr/test.txt"); fs.write("aAbBcCbDeEfF".getBytes()); 输出:    但我觉得直接输入到文件中文字太密不方便阅读。这时我们想到可以实现...

2018-03-11 12:24:12 170

原创 适配器模式(Adapter)

定义:将一个类的接口转换为客户希望的另外一个接口。举个例子先熟悉一下适配器模板代码客户希望的接口//在客户端被使用的接口public interface Target { public void request();}现在存在的类//已经存在的接口public class Adaptee { //示意方法 public void specificRequest() { }}...

2018-03-10 22:09:19 169

原创 观察者模式(Observer)

定义:定义对象间的一种一对多的依赖关系,当一个对象的状态发生改变时所有依赖于他的对象自动收到通知并跟新。举个例子:张三,李四,王五,收看CCTV(定义对象间的一种一对多的依赖关系) , CCTV放新闻张三,李四,王五收看新闻,CCTV放广告张三,李四,王五换台(一个对象的状态发生改变【CCTV】时所有依赖于他的对象自动收到通知并跟新)观察者模式的实现有固定套路首先我们先熟记模板代码。命名建议   ...

2018-03-10 20:06:32 206

原创 mygame项目简介

简介:本项目运用了SSM框架和BootStrap搭建内置了五个js游戏使得用户可以玩游戏参与排名,评论游戏,查询战绩,在线聊天。(在部署到阿里云服务器时WebSocket连接失败导致在线聊天功能不能用不知如何解决)后台管理员可以查询用户信息,修改游戏描述,删除用户评论。 一 登录页面    启动项目浏览器输入http://localhost:8080/mygame/即跳转到登录界面,点击注册注册新...

2018-03-10 10:03:28 746

原创 NIO整理

buffer的例子@Test public void test() { CharBuffer buffer = CharBuffer.allocate(8); System.out.println("capacity:"+buffer.capacity());//输出8 System.out.println("limit:"+buffer.limit());//输出8 Syst...

2018-03-07 10:53:43 142

原创 反射总结

用反射来实现一个可以读取配置生成对象的对象池public class ObjectPoolFactory { //定义一个对象池 名字 对应的对象 private Map<String,Object> map = new HashMap<>(); //传入一个字符串就能返回一个对象 private Object createObject(String clazz...

2018-03-06 20:03:21 171

原创 IO总结

File类的知识public static void main(String[] args) throws IOException { //以当前路径创建一个file对象 File file = new File("C:\\Users\\G410\\eclipse-workspace\\javase"); //直接获取文件名输出一点 System.out.println(fil...

2018-03-06 16:14:42 128

原创 注解总结

     Annotation 可用于修饰包 类 构造器 方法 成员变量 参数 局部变量 的声明这些信息存储在 Annation 的  name=value中Annotation是一个接口程序可以通过反射来获取指定程序元素的Annotation对象,然后通过Annotation对象获得注释里的元数据     元 Annotation只能用于修饰一个Annotation定义用于指定被修饰的Annot...

2018-03-06 12:13:19 175

原创 基本排序总结(Java 版)

快速排序快速排序的基本思想:通过一趟排序将待排序记录分割成独立的两部分,其中一部分记录的关键字均比另一部分关键字小,则分别对这两部分继续进行排序,直到整个序列有序。一趟排序的过程:用例  test:{49,38,65,97,76,13,27}在首位定两个指针  int l=0 , int r=7选择一个 值作为枢纽。比枢纽小的放左边,大于等于枢纽的放右边     i                ...

2018-03-04 16:00:57 155

原创

父节点下标(x-1)/2左子节点x*2+1;右子节点x*2+2堆的一个结点public class Node { private int iData; public Node(int key) { iData=key; } public void setKey(int id) { iData=id; } public int getKey() { return i...

2018-03-03 12:56:04 116

原创 java基础整理-1

位移操作符左移// << 左移操作符 把数向左移动在底位补0 int a=2; System.out.println(Integer.toBinaryString(a)); a<<=1; System.out.println(Integer.toBinaryString(a));结果右移int b=1024; System.out.println(...

2018-03-02 23:02:40 136

原创 线程池

1. 准备一个任务容器2. 一次性启动多个线程3. 刚开始任务容器是空的,所以线程都wait在上面。4. 直到一个外部线程往这个任务容器中扔了一个“任务”,就会有一个线程被唤醒notify5. 这个线程取出“任务”,并且执行这个任务,执行完毕后,继续等待下一次任务的到来。6. 如果短时间内,有较多的任务加入,那么就会有多个线程被唤醒,去执行这些任务。上面是线程池思路上的我们根据这几点大概设计一个线...

2018-03-02 21:47:20 173

原创 监听器

 监听器是一个专门用于对其他对象身上发生的事件或状态改变进行监听和相应处理的对象,当被监视的对象发生情况时,立即采取相应的行动。监听器其实就是一个实现特定接口的普通java程序,这个程序专门用于监听另一个java对象的方法调用或属性改变,当被监听对象发生上述事件后,监听器某个方法立即被执行。我们是写监听器去监听其他对象,那么我们如果想设计一个对象,让这个对象可以被别的对象监听又该怎么做呢,可以按照...

2018-03-01 23:44:23 8683

原创 策略模式

在策略模式(Strategy Pattern)中,一个类的行为或其算法可以在运行时更改。这种类型的设计模式属于行为型模式。在策略模式中,我们创建表示各种策略的对象和一个行为随着策略对象改变而改变的 context 对象。策略对象改变 context 对象的执行算法。意图:定义一系列的算法,把它们一个个封装起来, 并且使它们可相互替换。主要解决:在有多种算法相似的情况下,使用 if...else 所...

2018-03-01 20:09:39 156

原创 数据库连接池

        数据库连接是一种关键的有限的昂贵的资源,这一点在多用户的网页应用程序中体现的尤为突出.对数据库连接的管理能显著影响到整个应用程序的伸缩性和健壮性,影响到程序的性能指标.数据库连接池正式针对这个问题提出来的.数据库连接池负责分配,管理和释放数据库连接,它允许应用程序重复使用一个现有的数据库连接,而不是重新建立一个。    本人水平有限记性很差连接池原理看了忘,忘了看在这里我整理一下连...

2018-03-01 19:09:30 240

原创

顶点class Vertex { public char label; public boolean wasVisited; public Vertex(char lab) { label=lab; wasVisited=false; } } 顶点对象放在数组中然后用下标指示用数组vertexList存储顶点对象。顶点也可以放在链表或其他数据结构中。图搜...

2018-02-23 21:02:25 131

原创 二叉树总结

二叉树基本性质:*根 root 节点度<=2 *儿子有序 左儿子 右儿子*第level层的节点个数最多为:2^(level-1)*深度为h的二叉树最多节点个数为2^h-1满二叉树基本性质:*节点个数=2^h-1*节点层次=[log2 i]+1*父节点 i=1根 i>1或 i<1 父节点=[i/2]完全二叉树基本性质: * 具有满二叉树大部分性质 * 仅有最后一层缺失部分节点 * ...

2018-02-22 15:02:56 187

原创 猫狗收容所

  题目描述:   有家动物收容所只收留猫和狗,但有特殊的收养规则,收养人有两种收养方式,第一种为直接收养所有动物中最早进入收容所的,第二种为选择收养的动物类型(猫或狗),并收养该种动物中最早进入收容所的。       给定一个操作序列int[][2] ope(C++中为vector<vector<int>>)代表所有事件。若第一个元素为1,则代表有动物进入收容所,第二个元...

2018-02-19 20:20:07 301

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除