自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

nianhua120的专栏

转载请注明csdn的地址,谢谢。

  • 博客(130)
  • 资源 (14)
  • 收藏
  • 关注

原创 Vetx.x : EventLoop线程不要锁(Synchronized/ReentrantLock)

Vetx.x : EventLoop线程不要锁(Synchronized/ReentrantLock)vert.x 里面有eventloop线程,而且eventloop线程是绝对不能阻塞的,但是实际使用中,有时候我们对阻塞理解不深刻,所以一些隐藏的阻塞没有那么好发现。eventloop 线程和work线程共用相同的锁下面的代码是一个简单的例子,用户请求localhost:8133/sync的时候会在

2017-09-18 17:50:08 1160

原创 merge-sort-call-tree-graph

merge-sort-call-tree-graph实现归并排序的递归调用图最近为了给一个学归并排序的同学搞懂递归调用的过程,在纸上画了整个递归调用的流程,及其每次调用传递的参数以及执行后的相应结果. 感觉非常适合教学使用,随用js自动画了个图,方便大家学习.程序划分虽然这个程序是js写成的,但是由于教学对象是学C的,所以贴的代码仍然是C的. 我们把归并排序的过程分为5步,在下面的注释中可以看到

2017-07-27 20:02:18 375

原创 Java8 Stream 的并发

Java8 Stream 并发 parrallel foreach

2016-11-30 13:15:02 4362

原创 发票整理问题算法

问题描述4个部门向财务部小李上共交了40张共计1000k元发票,所有发票抬头一样,金额不一样。小李不小心打乱了这些发票,但是知道每个部门报销的金额分别为,300k,200k,400k,100k,现在你能否帮助小李将这些发票凑成4份,满足上面4个项目组的各自金额之和。设计算法实现。思考1看到这个问题首先想到的数学方程,先列个表格,0,表示不使用,1,表示使用, 方程 n表示发...

2018-03-16 10:37:05 1337

原创 幂等操作——防止客户端重复提交

如果我们要一个客户端请求扣费100元,用户数据库有1000元。 那么执行sqlupdate  accounts set current= current-100 where id=123456如果我们这个sql语句执行成功了,但是http由于偶然性的断开,客户端会重试提交扣费请求,这样就会扣两次费用。 如果我们添加一个订单表detail,事务操作变成了begin trans...

2018-02-11 14:59:35 1589

原创 棋盘覆盖

题目要求在棋盘覆盖问题中,要用下图—图(2)所示的4种不同形态的L型骨牌覆盖一个给定的特殊棋盘上除特殊方格以外的所有方格,且任何2个L型骨牌不得重叠覆盖运行结果 /* * Copyright (c) 2017, CipherGateway and/or its affiliates. All rights reserved. * */import javafx.application.Ap

2017-09-13 14:20:01 592

原创 dva的roadhogrc配置文件webstorm或idea解析

这是一款dva项目的.roaghogrc的idea 或者webstorm解析插件dva改用roadhog框架之后,配置文件改为了.roadhogrc, 但是该文件虽然是标准json格式,但是后缀却不是.json, idea或者webstom无法直接解析,这让人很容易错写格式。 为了满足webstorm或者idea平台下开发项目, 我们实现了.roadhogrc文件的webstorm或idea

2017-08-29 17:43:45 8277

原创 点击删除一列

javascript点击删除表格一列最近有同学问我如何点击删除购物车的一列。我想想我是用react的,只需要删除数据中的一列,然后视图就自动删除了。但是这儿就必须用原生js,那只好去网上找找了。然后写了个列子,供大家参考吧。<html><head><style>table, td { border: 1px solid black; width: 300px;}</sty

2017-08-10 11:05:55 485

原创 关于实现在阿里的Antd的Modal上实现动态表的一种思路

关于实现在阿里的Antd的Modal上实现动态表的一种思路问题描述有一种业务场景,就是我们需要在一个Modal中实现动态添加表单项。并且在该Modal期间会触发状态树的更改,比如你在Modal上填写了一堆数据 然后点击提交按钮,数据被提交到后台,可是后台发现数据不满足需求,返回了错误信息。此时你希望Modal仍然能显示出来,并且包含已经填写过 的信息。但是当用户点击新建按钮时候,你又希望这个

2017-08-02 11:07:08 10210 1

原创 动态配置配置文件路径

动态配置配置文件路径应用场景做项目中经常问出现开发环境和生产环境配置文件路径不一样的情况。对于这样的问题,我们可没必要给每个环境准备一套代码。解决方法我们可以通过传递不同的vm 参数来实现动态路径。 参考代码如下。

2017-03-17 19:35:05 1001

原创 缓存

关于串行和并行的思考最近一个项目中有如下一个应用场景:我们实时记录用户的行为,并产生日志,每次产生一条日志的时候,我们就通过一系列规则来判断这个行为是否属于用户监控的行为。 监测日志行为的规则不止一条,而且具有优先级,如果该日志满足多条规则时候,以最高规则为准,处理用户的行为。我们以前实现的代码如下:Filter saveLog(Log log){ //在执行前,已经按优先级将filters排序

2017-03-10 23:05:17 228

原创 Java 8下的工厂模式

Java 8下的工厂模式你肯定厌倦了传统工厂模式的switch或者if else 模式, 如下public static Factory{ public Sample creator(String string){ switch(string){ "apple": return new Apple(); "car": return new Car();

2016-12-08 21:27:36 498

原创 Java8下重构log

重构log本文属于个人 读 Java8 in action 的感悟笔记lambda表达式具有懒加载的特性,我们看一个案例。最最原始的logger用法如下 if(logger.enabled()){ logger.debug("debug: " + getInfo(foo));}如果程序中用到这样的地方很多,那么程序写出来肯定会很难看,我们一般会封装成一个函数void log(String

2016-12-04 17:18:34 553

原创 基于React,dva脚手架的知乎日报

MyZhihuApp1,初始化npm install dvanpm install dva-cli -gmkdir MyZhiHuAppDvadva -initnpm start浏览器打开localhost:8989 你就可以看到欢迎界面了2,修改页面打开/routes/IndexPage.less,改为:.normal { margin: 50px; text-align: ce

2016-10-25 10:57:52 15301

原创 React-Redux-Antd实现知乎日报项目(一)

最近刚学习React,决定实现一个稍微复杂完整的项目,实战一下React-Redux-Antd等库开发环境配置Ubuntu16.041,开发软件 sudo apt install npmsudo apt install git2,采用atom作为编辑器3,采用react-start-kit 作为脚手架$ git clone https://github.com/

2016-10-10 21:49:02 4547

原创 LeetCode 138. Copy List with Random Pointer

A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null.Return a deep copy of the list.这个题目想了好久,觉得应该用HashMap 之类

2016-08-10 15:43:52 327

原创 LeetCode82.Remove Duplicates from Sorted List II

Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.For example,Given 1->2->3->3->4->4->5, return 1->2->5.Given 1->

2016-08-08 14:48:20 258

原创 LeetCode80. Remove Duplicates from Sorted Array II

Follow up for "Remove Duplicates":What if duplicates are allowed at most twice?For example,Given sorted array nums = [1,1,1,2,2,3],Your function should return length = 5, with the first fi

2016-08-08 14:06:47 228

原创 LeetCode 110. Balanced Binary Tree

Given 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 every node never dif

2016-08-05 17:34:53 257

原创 114. Flatten Binary Tree to Linked List

Given a binary tree, flatten it to a linked list in-place.For example,Given 1 / \ 2 5 / \ \ 3 4 6The flattened tree should look like: 1

2016-08-05 16:55:11 222

原创 LeetCode 242. Valid Anagram

Given two strings s and t, write a function to determine if t is an anagram of s.For example,s = "anagram", t = "nagaram", return true.s = "rat", t = "car", return false.Note:You may ass

2016-08-04 14:39:16 212

原创 LeetCode105. Construct Binary Tree from Preorder and Inorder Traversal

Given preorder and inorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.这种类型的题目经常考选择题。对于这道题,采用的是分治的思想,通过preorder的第一个元素为根元素,将ino

2016-08-04 13:11:15 194

原创 LeetCode 116. Populating Next Right Pointers in Each Node

Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; }Populate each next pointer to point to its next right node.

2016-08-04 09:44:27 182

原创 LeetCode 40. Combination Sum II

Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.Each number in C may only be used once in the combi

2016-07-28 14:39:56 198

原创 LeetCOde 64. Minimum Path Sum

Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path.Note: You can only move either down or right at

2016-07-28 13:39:32 184

原创 LeetCode 234. Palindrome Linked List

Given a singly linked list, determine if it is a palindrome.Follow up:Could you do it in O(n) time and O(1) space?要在O(N)时间,O(1)空间完成,必须得反转链表,思路如下。1,通过快慢指针找到中心位置。2,以中心为线,将前面的链表反转3,通过

2016-07-28 11:19:55 222

原创 LeetCode 257. Binary Tree Paths

Given a binary tree, return all root-to-leaf paths.For example, given the following binary tree: 1 / \2 3 \ 5All root-to-leaf paths are:["1->2->5", "1->3"]树的遍历,相当简单

2016-07-28 10:51:24 205

原创 LeetCode 203. Remove Linked List Elements

Remove all elements from a linked list of integers that have value val.ExampleGiven: 1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6, val = 6Return: 1 --> 2 --> 3 --> 4 --> 5Credits:Special thanks

2016-07-27 11:33:46 181

原创 LeetCode344. Reverse String

Write a function that takes a string as input and returns the string reversed.Example:Given s = "hello", return "olleh".这个题目考察O(1)空间交换数组的。public class Solution { public String reve

2016-07-26 17:23:56 177

原创 LeetCode 130 Surrounded Regions

Given a 2D board containing 'X' and 'O' (the letter O), capture all regions surrounded by 'X'.A region is captured by flipping all 'O's into 'X's in that surrounded region.For example,

2016-07-26 15:50:22 257

原创 Leetcode 139, Word Break

Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words.For example, givens = "leetcode",dict = ["leet"

2016-07-25 15:08:49 218

原创 LeetCode 143. Reorder List

Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…You must do this in-place without altering the nodes' values.For example,Given {1,2,3,4}, reorder it t

2016-07-25 10:58:12 250

原创 LeetCode 93. Restore IP Addresses

Given a string containing only digits, restore it by returning all possible valid IP address combinations.For example:Given "25525511135",return ["255.255.11.135", "255.255.111.35"]. (Order

2016-07-22 15:09:27 190

原创 LeetCode 226. Invert Binary Tree

Invert a binary tree. 4 / \ 2 7 / \ / \1 3 6 9to 4 / \ 7 2 / \ / \9 6 3 1这道题和判断树的对称性是一样的递归翻转左右子树。/** * Definition for a binary tree node. *

2016-07-21 11:18:09 210

原创 LeetCode 129. Sum Root to Leaf Numbers

iven a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number.An example is the root-to-leaf path 1->2->3 which represents the number 123.Find the total

2016-07-21 11:13:39 224

原创 LeetCode 39. Combination Sum

Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.The same repeated number may be chosen from C unlimited numb

2016-07-20 16:36:14 212

原创 LeetCode 67. Add Binary

Given two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "100".一位一位的加就行了,考虑溢出。public class Solution { public String addBinary(String a, S

2016-07-20 14:25:45 175

原创 LeetCode 53. Maximum Subarray

Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array [−2,1,−3,4,−1,2,1,−5,4],the contiguous subarray [4,−1,2,1] ha

2016-07-20 12:21:20 209

原创 LeetCode 57. Insert Interval

Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary).You may assume that the intervals were initially sorted according to their start times.E

2016-07-15 13:36:37 175

原创 LeetCode 27. Remove Element

Given an array and a value, 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 in place with constant memory.

2016-07-12 20:17:48 274

MyJamseMusicV5

http://blog.csdn.net/nianhua120/article/details/51530879

2016-06-04

MyJamseMusicV4

http://blog.csdn.net/nianhua120/article/details/51527343

2016-06-04

MyJamsMusicV2

http://blog.csdn.net/nianhua120/article/details/51510297

2016-06-04

MyJamsMusicV1

http://blog.csdn.net/nianhua120/article/details/51570524

2016-06-04

SwipeMenuListViewV8

http://blog.csdn.net/nianhua120/article/details/51474593

2016-05-22

SwipeMenuListViewV7

http://blog.csdn.net/nianhua120/article/details/51428331

2016-05-22

MySwipeMenuListViewV4

资源的详细描述见 http://blog.csdn.net/nianhua120/article/details/51415912

2016-05-15

MySwipeMenuListView3

本代码说明详见 http://blog.csdn.net/nianhua120/article/details/51405522

2016-05-14

FrameLayout动态布局

该资源与文章http://blog.csdn.net/nianhua120/article/details/51387668 相配套。详细请参考该文章。

2016-05-14

MySwipeMenuListView1

这是我仿写的SwipeMenuListView的第一章节,只实现了手指移动的监测功能。

2016-05-11

STM32F0系列参考例程

该例程不是官方开发板的例程,而是我买的开发板赠送的。包括了IO口,SPI,DMA,USART等。基本上每个模块都有了。学习STM32的同学拿去。该开发板为STM32F051,凡是STM32F0xx系列的都行。

2012-08-30

c#串口配置窗体(可用于继承窗体)serialport类

这是一个用c#写的窗口配置窗体。包含了异常处理。使用serialport组件。适合win7,xp,vista等。可以生产dll文件,用于继承窗体。很是方便。

2012-02-25

单片机钢琴protel+keil仿真程序 下下来即可运行

这是一个用单片机仿真的电子钢琴程序,对单片机初学者来说是一个很不错的列子,文件包括protel仿真及keil写的汇编代码。相当好用奥。

2011-05-05

单片机数码管动态显示源程序及仿真电路文件

这是一个完整的带仿真电路的单片机动态显示数码管程序,希望对大家有用。protel和keil仿真奥。

2011-05-02

空空如也

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

TA关注的人

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