Skip to content

2017编程提高群第2季 912867333请求fork #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 689 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
689 commits
Select commit Hold shift + click to select a range
29e4066
Merge pull request #4 from onlyliuxin/master
Jun 26, 2017
de9cb62
add homework for UML
Jun 26, 2017
c73d55c
ocp commit, 支持观察者
Jun 26, 2017
f6588e4
线程池使用1
miniyk2012 Jun 26, 2017
0738eb4
投骰子-代码部分
miniyk2012 Jun 26, 2017
2e94530
修改骰子的点数
miniyk2012 Jun 26, 2017
6840030
投骰子uml图
miniyk2012 Jun 26, 2017
cf5b22c
uml homework01
Jun 27, 2017
b9dcd70
srp homework
Jun 27, 2017
46f1749
read the file and resolve a line to a product.
ThomsonTang Jun 27, 2017
8bfc3ed
add a resource directory.
ThomsonTang Jun 27, 2017
7bd719e
购物网站用例图
miniyk2012 Jun 27, 2017
f4f6ef8
放大类图
miniyk2012 Jun 27, 2017
adea855
ocp homework
Jun 28, 2017
171e348
UML作业(dice game / shopping)
MIMIEYES Jun 28, 2017
a0496c3
refactor srp
Jun 29, 2017
0ab140f
refactor the promotion email project.
ThomsonTang Jun 29, 2017
2bc74af
单一职责作业
Jun 30, 2017
52f16e2
开闭原则作业
Jul 1, 2017
8d716de
refactor the promotion email project.
ThomsonTang Jul 2, 2017
35e5c7b
Merge pull request #474 from chasing95/master
onlyliuxin Jul 2, 2017
2b343ab
Merge pull request #2 from onlyliuxin/master
eulerlcs Jul 2, 2017
f69a583
第一次srp重构作业
Jul 2, 2017
6d58113
add regular expression project
eulerlcs Jul 2, 2017
431217d
第一次作业
em14Vito Jul 2, 2017
a66c7ab
Merge pull request #4 from onlyliuxin/master
miniyk2012 Jul 3, 2017
616cf8d
payroll
onlyliuxin Jul 4, 2017
e49ac3d
Merge pull request #478 from em14Vito/master
onlyliuxin Jul 4, 2017
d7270d2
Merge pull request #477 from imhuster/master
onlyliuxin Jul 4, 2017
96092ed
Merge pull request #1 from onlyliuxin/master
wluqing Jul 4, 2017
82c7cd3
Merge remote-tracking branch 'upstream/master'
Jul 4, 2017
e01d178
add project of payment
Jul 4, 2017
5813a06
Merge pull request #5 from onlyliuxin/master
miniyk2012 Jul 4, 2017
b714cf0
Payroll init
miniyk2012 Jul 4, 2017
70023ec
Merge pull request #476 from ThomsonTang/master
onlyliuxin Jul 5, 2017
6dfa138
Merge pull request #470 from MIMIEYES/master
onlyliuxin Jul 5, 2017
67e4eb4
Merge pull request #463 from starlight0405/master
onlyliuxin Jul 5, 2017
16fbe95
desktop commit
wluqing Jul 5, 2017
731e7e1
commit test
wluqing Jul 5, 2017
f20bea2
commit test2
wluqing Jul 5, 2017
f03f7ba
commit test undo
wluqing Jul 5, 2017
9c5a25d
commit test
wluqing Jul 5, 2017
048230a
commit and push test
wluqing Jul 5, 2017
fd74ffc
undo commit
wluqing Jul 5, 2017
0d1fbd3
Merge pull request #482 from wluqing/master
onlyliuxin Jul 6, 2017
30d1cb3
Merge pull request #457 from ISmallBlack/master
onlyliuxin Jul 6, 2017
89de58a
Merge pull request #1 from onlyliuxin/master
harryhook Jul 6, 2017
9a73b97
Merge remote-tracking branch 'upstream/master'
dustheart Jul 7, 2017
5b331b9
Merge pull request #1 from onlyliuxin/master
chasing95 Jul 7, 2017
aaf47e1
update
Jul 7, 2017
e853747
Merge pull request #4 from onlyliuxin/master
lorcx Jul 8, 2017
5be0c63
payroll
Jul 9, 2017
b5f9d48
Revert "payroll"
Jul 9, 2017
aba6c86
payroll
Jul 9, 2017
2ae6521
Merge branch 'master' of https://github.com/guoshenghui/coding2017
Jul 9, 2017
9d5a994
2017年7月9日 15:33:22
lorcx Jul 9, 2017
c5cdc21
payroll code
onlyliuxin Jul 10, 2017
323a02a
payroll code
onlyliuxin Jul 10, 2017
22d8938
paroll code
onlyliuxin Jul 10, 2017
cb12f47
Merge pull request #462 from guoshenghui/master
onlyliuxin Jul 10, 2017
4e92eff
Merge pull request #454 from yyglider/master
onlyliuxin Jul 10, 2017
e6e5cf8
Merge pull request #453 from fengdzh/master
onlyliuxin Jul 10, 2017
b358bd5
Merge pull request #452 from Rancher-V/master
onlyliuxin Jul 10, 2017
faa1a3a
Merge pull request #449 from HarryHook/master
onlyliuxin Jul 10, 2017
9f2c2ae
Merge pull request #447 from miniyk2012/master
onlyliuxin Jul 10, 2017
2330282
Merge pull request #445 from YouHmilyForProgramming/master
onlyliuxin Jul 10, 2017
209c893
Merge pull request #442 from skomefen/master
onlyliuxin Jul 10, 2017
12769d2
Merge pull request #440 from yangzhm/master
onlyliuxin Jul 10, 2017
3125a34
Merge pull request #437 from GordenChow/master
onlyliuxin Jul 10, 2017
89d9463
Merge pull request #436 from javmin/master
onlyliuxin Jul 10, 2017
fc122f1
Merge pull request #433 from ShiningChenCode/master
onlyliuxin Jul 10, 2017
483827e
Merge pull request #429 from szfck/master
onlyliuxin Jul 10, 2017
17e1f55
Merge pull request #428 from 15993061515/master
onlyliuxin Jul 10, 2017
13b44e6
Merge pull request #427 from WANGCANCER/master
onlyliuxin Jul 10, 2017
f17529d
Merge pull request #426 from Tony-Hu/master
onlyliuxin Jul 10, 2017
e0bb3fa
Merge pull request #425 from johnChnia/master
onlyliuxin Jul 10, 2017
edc5836
Merge pull request #423 from Ken-W-P-Huang/master
onlyliuxin Jul 10, 2017
1b68f6c
Merge pull request #422 from GUK0/master
onlyliuxin Jul 10, 2017
3aa27a3
payroll code
onlyliuxin Jul 10, 2017
a98dea4
tag builder
onlyliuxin Jul 10, 2017
e69f85c
第一次作业linxin目录下文件修改误提交,现在重提交
KeXianlin Jul 10, 2017
ee0d8c7
Merge remote-tracking branch 'upstream/master'
dustheart Jul 11, 2017
34e00d5
uml homework
Jul 11, 2017
096522a
添加正则表达式用例
eulerlcs Jul 11, 2017
3a498c3
Merge pull request #3 from onlyliuxin/master
eulerlcs Jul 11, 2017
5c16127
add regexp project
eulerlcs Jul 12, 2017
d60b463
Merge pull request #496 from eulerlcs/20170712.regexp
onlyliuxin Jul 12, 2017
68c954c
Merge remote-tracking branch 'upstream/master'
dustheart Jul 13, 2017
76c02c1
Merge pull request #491 from readke/master
onlyliuxin Jul 13, 2017
2a2be7c
Merge pull request #492 from starlight0405/master
onlyliuxin Jul 13, 2017
c5a3784
payroll
Jul 13, 2017
fc45289
20170715
lorcx Jul 15, 2017
8aff298
2017年7月15日 10:24:52
lorcx Jul 15, 2017
868e836
解锁
lorcx Jul 15, 2017
7dc43e6
修改结构目录
lorcx Jul 15, 2017
e976ae3
修改为maven项目
lorcx Jul 15, 2017
e4d6ff4
提交
lorcx Jul 15, 2017
63b2401
2017年7月15日 13:01:19
lorcx Jul 15, 2017
dfca194
2017年7月15日 13:01:19
lorcx Jul 15, 2017
c70aaf7
2017年7月15日 13:01:19
lorcx Jul 15, 2017
ede72d4
2017年7月15日 13:01:19
lorcx Jul 15, 2017
b7e6dc5
Merge pull request #5 from onlyliuxin/master
lorcx Jul 15, 2017
2629e03
Merge pull request #2 from onlyliuxin/master
mysqlfront Jul 16, 2017
510dcfd
薪水支付系统任务
chasing95 Jul 16, 2017
3c2f342
add project of builder pattern
Jul 17, 2017
d038521
atm homework
Jul 17, 2017
0d0ebf0
fix bug
onlyliuxin Jul 17, 2017
966ea34
Merge branch 'master' of https://github.com/onlyliuxin/coding2017
onlyliuxin Jul 17, 2017
dbc9dd2
remove unused file
onlyliuxin Jul 17, 2017
4aec6b8
Merge pull request #6 from onlyliuxin/master
miniyk2012 Jul 17, 2017
5d7ace3
Builder作业
miniyk2012 Jul 17, 2017
709cb25
Merge pull request #509 from chasing95/master
onlyliuxin Jul 18, 2017
3c034cd
Merge remote-tracking branch 'onlyliuxin/master'
GordenChow Jul 18, 2017
d20ea19
正则表达式init
miniyk2012 Jul 18, 2017
27b07be
regex调试
miniyk2012 Jul 18, 2017
9f32ea3
模板替换
miniyk2012 Jul 18, 2017
b9815bb
Add Builder homework
jjyyjjyy Jul 19, 2017
10cd690
正则2
miniyk2012 Jul 19, 2017
27d3f86
Little fix
miniyk2012 Jul 19, 2017
8b1df6c
正则表达式3
miniyk2012 Jul 19, 2017
57a3406
提交builder作业
GordenChow Jul 21, 2017
28ee497
Merge pull request #5 from onlyliuxin/master
Jul 21, 2017
892f1bc
分别实现了两层嵌套和多层嵌套的XML结点生成器
Jul 21, 2017
bc2ecb5
tagBuilder and singleton
Jul 21, 2017
06dae99
Merge pull request #6 from onlyliuxin/master
lorcx Jul 22, 2017
b757eef
builder
Jul 22, 2017
c813af6
Merge pull request #7 from onlyliuxin/master
miniyk2012 Jul 23, 2017
be6e24a
2017年7月23日 15:35:11
lorcx Jul 23, 2017
94a5da4
add implementation code
onlyliuxin Jul 23, 2017
f1e2595
Merge branch 'master' of https://github.com/onlyliuxin/coding2017
onlyliuxin Jul 23, 2017
bfd3d88
add composite pattern
onlyliuxin Jul 23, 2017
f69d4e3
add bridge pattern
onlyliuxin Jul 23, 2017
8807be3
builder
Jul 23, 2017
aa66ae2
Merge pull request #8 from onlyliuxin/master
miniyk2012 Jul 23, 2017
c916996
[CI] 把老师的代码移动到我的目录中
miniyk2012 Jul 23, 2017
8c2973b
[feature] atm说明文件
miniyk2012 Jul 23, 2017
86a0289
20170724_1544_homework
orajavac Jul 24, 2017
a4797a1
[feature] bridge(桥接)模式
miniyk2012 Jul 24, 2017
5e10c45
[feature] 装饰者模式
miniyk2012 Jul 25, 2017
b8a86a5
Merge pull request #528 from orajavac/master
onlyliuxin Jul 25, 2017
0a0c646
Merge pull request #526 from lorcx/master
onlyliuxin Jul 25, 2017
bbc6b4f
Merge pull request #524 from guoshenghui/master
onlyliuxin Jul 25, 2017
210f773
Merge pull request #522 from lanyuanxiaoyao/master
onlyliuxin Jul 25, 2017
b8ce344
Merge pull request #521 from GordenChow/master
onlyliuxin Jul 25, 2017
3f47a6f
Merge pull request #516 from jy97799/master
onlyliuxin Jul 25, 2017
4b68c39
Merge pull request #513 from miniyk2012/master
onlyliuxin Jul 25, 2017
9e514d7
Merge pull request #512 from starlight0405/master
onlyliuxin Jul 25, 2017
01331f6
Merge pull request #511 from yangzhm/master
onlyliuxin Jul 25, 2017
77d3fdd
[feature] 实现组合(Composite)模式
miniyk2012 Jul 25, 2017
86e72d7
Merge pull request #9 from onlyliuxin/master
miniyk2012 Jul 26, 2017
d1a785b
Add Decorator&Composition&Bridge pattern homework
jjyyjjyy Jul 27, 2017
ef5a658
dp homework
Jul 28, 2017
f6062be
add homework of bridgepattern,compositepattern and decoratorpattern
Jul 28, 2017
61bbb64
Merge pull request #7 from onlyliuxin/master
lorcx Jul 29, 2017
08e5727
作业提交
lorcx Jul 29, 2017
eb15c6a
7-23日作业
mingming-lu Jul 30, 2017
155bd79
[Feature] ATM初步实现
miniyk2012 Jul 30, 2017
fe51642
[Feature] ATM取款机,完成取款和存款2个交易类型
miniyk2012 Jul 30, 2017
b97e05e
[Feature] ATM实现2
miniyk2012 Jul 30, 2017
e4590f3
[Fix]: 修改若干测试用例
miniyk2012 Jul 30, 2017
30d4ab3
dp
Aug 2, 2017
2bc90ba
作业3:实现装饰者
bendell02 Aug 2, 2017
2d33ec7
作业4:实现Composite
bendell02 Aug 2, 2017
dce082a
作业5:实现Bridge
bendell02 Aug 2, 2017
159f3d7
Merge remote-tracking branch 'upstream/master'
Aug 6, 2017
348d93f
Merge pull request #530 from miniyk2012/master
onlyliuxin Aug 6, 2017
afb0fe3
Merge pull request #531 from jy97799/master
onlyliuxin Aug 6, 2017
225c1a7
Merge pull request #532 from starlight0405/master
onlyliuxin Aug 6, 2017
ca88ec1
Merge pull request #533 from yangzhm/master
onlyliuxin Aug 6, 2017
b38fffa
Merge pull request #538 from akinaru-lu/master
onlyliuxin Aug 6, 2017
7c9c270
Merge pull request #540 from lorcx/master
onlyliuxin Aug 6, 2017
3db6b14
Merge pull request #542 from guoshenghui/master
onlyliuxin Aug 6, 2017
7f7f43d
Merge pull request #544 from bendell02/master
onlyliuxin Aug 6, 2017
2171412
1241588932:设计模式第一次作业
Aug 6, 2017
937cbc9
Merge pull request #10 from onlyliuxin/master
miniyk2012 Aug 8, 2017
3a70043
Merge pull request #8 from onlyliuxin/master
lorcx Aug 9, 2017
4f2e0cc
[Fix] 增加一个junit3风格的用例
miniyk2012 Aug 9, 2017
86f6e96
Merge branch 'master' of https://github.com/miniyk2012/coding2017
miniyk2012 Aug 9, 2017
6d95c23
add project of responsibility chain pattern and command pattern
Aug 10, 2017
3e87b07
[Train] 责任链模式尝试
miniyk2012 Aug 10, 2017
93c5373
2017年8月10日23:00:56
Aug 10, 2017
49d2800
[Homework] 责任链模式
miniyk2012 Aug 10, 2017
ed6fab7
[Homework]: 命令模式
miniyk2012 Aug 11, 2017
f39df1c
chain and command design homework
Aug 11, 2017
e1eb52b
Add Command&Chain pattern homework
jjyyjjyy Aug 12, 2017
1cc9400
作业提交
lorcx Aug 12, 2017
7cdd0cf
assignment 0806
mingming-lu Aug 13, 2017
b8fd934
lite-junit v1
onlyliuxin Aug 13, 2017
7e60c87
Merge pull request #11 from onlyliuxin/master
miniyk2012 Aug 13, 2017
9e9c144
Merge pull request #9 from onlyliuxin/master
lorcx Aug 15, 2017
61d566a
Merge pull request #2 from onlyliuxin/master
250103158 Aug 17, 2017
4b02dc5
add project of LiteJUnit
Aug 18, 2017
b79097c
junit
Aug 19, 2017
c46ab2e
[Feature] 刘老师的junit-v1 init
miniyk2012 Aug 20, 2017
2e666a7
[Fix] add comment in liuxin lite-junit-v1
miniyk2012 Aug 20, 2017
207d461
[Homework] 完成v1版本的TestCase
miniyk2012 Aug 20, 2017
197b219
lite-junit v2,v3
onlyliuxin Aug 21, 2017
dcc72f2
[Feature] test v1 done
miniyk2012 Aug 22, 2017
6ce9ad6
Merge pull request #12 from onlyliuxin/master
miniyk2012 Aug 22, 2017
9139171
[Fix] add subtle
miniyk2012 Aug 22, 2017
ab8980d
Merge branch 'master' of https://github.com/miniyk2012/coding2017
miniyk2012 Aug 22, 2017
e3e452b
Merge pull request #10 from onlyliuxin/master
lorcx Aug 26, 2017
bc0d3b3
Merge pull request #562 from 250103158/master
honokaBiu Aug 26, 2017
0a69288
Merge pull request #546 from Enan01/master
honokaBiu Aug 26, 2017
221c295
Merge pull request #559 from akinaru-lu/master
honokaBiu Aug 26, 2017
2ecc679
Merge pull request #558 from miniyk2012/master
honokaBiu Aug 26, 2017
976b0f7
Merge pull request #556 from lorcx/master
honokaBiu Aug 26, 2017
a2c9fec
Merge pull request #554 from jy97799/master
honokaBiu Aug 26, 2017
0530dfe
Merge pull request #553 from starlight0405/master
honokaBiu Aug 26, 2017
dddbc14
Merge pull request #551 from yangzhm/master
honokaBiu Aug 26, 2017
0a6ebbc
TestListener
Aug 27, 2017
96083b1
extension
Aug 27, 2017
1cb1d92
完成V1版junit
zzJohnH Sep 1, 2017
e6d45df
lite-junitV2完成
zzJohnH Sep 3, 2017
3e28735
Merge pull request #13 from onlyliuxin/master
miniyk2012 Sep 3, 2017
15c478b
[Feature] java的闭包,用内部类实现
miniyk2012 Sep 3, 2017
cbe7103
Merge branch 'master' of https://github.com/miniyk2012/coding2017
miniyk2012 Sep 3, 2017
a920b56
JUnit3类图和时序图
zzJohnH Sep 4, 2017
966ccbb
litejunitV3完成
zzJohnH Sep 6, 2017
f30c364
JUnit4.0类图
zzJohnH Sep 6, 2017
8001514
修改JUnit3时序图,添加创建TestSuite动作
zzJohnH Sep 8, 2017
9cc9e2b
完成JUnitV4.0时序图
zzJohnH Sep 9, 2017
9024208
删除Junit.gliffy
zzJohnH Sep 9, 2017
eba9a56
v2版本添加功能RepeatedTest
zzJohnH Sep 9, 2017
ae96cdf
Merge pull request #573 from johnChnia/master
onlyliuxin Sep 12, 2017
3b767d3
第二季度作业
wanghongdi56 Sep 14, 2017
2b64d13
Merge pull request #14 from onlyliuxin/master
miniyk2012 Sep 14, 2017
058747b
Merge pull request #3 from onlyliuxin/master
mysqlfront Sep 15, 2017
adc9847
完成
Maneng Sep 15, 2017
d7e7296
[Add] 老师代码先搬过来
miniyk2012 Sep 16, 2017
676ceb2
[Feature] 薪水支付DataBase设计
miniyk2012 Sep 16, 2017
5d54986
[Feature] 完成临时工,雇员,销售的工作计算方法
miniyk2012 Sep 16, 2017
df54909
[Feature] 支付方式和发薪日 done
miniyk2012 Sep 16, 2017
40795b6
jyz薪水支付,junit
mysqlfront Sep 16, 2017
d89f51c
[Feature] 完成协会工资扣减
miniyk2012 Sep 16, 2017
83d86fd
[Feature] 完成定时任务,测试驱动,发薪逻辑
miniyk2012 Sep 17, 2017
67b16a8
[Fix] 删除老师的代码
miniyk2012 Sep 17, 2017
2d7420f
[Fix] 循环不需要终止
miniyk2012 Sep 17, 2017
1bc48b1
[Feature] junt-v2 init
miniyk2012 Sep 17, 2017
8a17419
[Feature] add testSuite and let it run
miniyk2012 Sep 17, 2017
e0c6e1f
junit3.x
Sep 17, 2017
ec22796
[Feature] add simple Listener
miniyk2012 Sep 17, 2017
1b5b72a
[Feature] 装饰器模式:RepeatedTest和SetUpTest
miniyk2012 Sep 17, 2017
611ccb3
[Feature] 增加README.md, 补充改进点和使用的模式
miniyk2012 Sep 17, 2017
68d467e
Merge pull request #582 from guoshenghui/master
onlyliuxin Sep 18, 2017
b54dbd2
Merge pull request #581 from mysqlfront/master
onlyliuxin Sep 18, 2017
d18de2b
Merge pull request #580 from Maneng/master
onlyliuxin Sep 18, 2017
571a95b
Merge pull request #578 from miniyk2012/master
onlyliuxin Sep 18, 2017
703c74a
Merge pull request #576 from wanghongdi56/master
onlyliuxin Sep 18, 2017
e98e184
Merge pull request #574 from dustheart/master
onlyliuxin Sep 18, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
16 changes: 16 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,22 @@ target
liuxin/.DS_Store
liuxin/src/.DS_Store

students/1005475328/*
students/1329920463/*
students/1452302762/*
students/14703250/*
students/2842295913/*
students/383117348/*
students/404481481/*
students/406400373/*
students/549739951/*
students/582161208/*
students/592146505/*
students/844620174/*
students/87049319/*
students/183549495/*





Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,5 +104,7 @@ public void testIsValid() {
public void testGetNodesBetween(){
List<Integer> numbers = this.tree.getNodesBetween(3, 8);
Assert.assertEquals("[3, 4, 5, 6, 8]",numbers.toString());
numbers = this.tree.getNodesBetween(1, 8);
Assert.assertEquals("[1, 2, 3, 4, 5, 6, 8]",numbers.toString());
}
}
32 changes: 32 additions & 0 deletions liuxin/knowledge-point/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<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/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.coderising</groupId>
<artifactId>knowledge-point</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>knowledge-point</name>
<url>http://maven.apache.org</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>

</dependencies>
<repositories>
<repository>
<id>aliyunmaven</id>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
</repository>
</repositories>
</project>
18 changes: 18 additions & 0 deletions liuxin/knowledge-point/src/main/java/cas/CASSequence.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package cas;

import java.util.concurrent.atomic.AtomicInteger;

public class CASSequence{

private AtomicInteger count = new AtomicInteger(0);

public int next(){
while(true){
int current = count.get();
int next = current +1;
if(count.compareAndSet(current, next)){
return next;
}
}
}
}
34 changes: 34 additions & 0 deletions liuxin/knowledge-point/src/main/java/cas/NoBlockingStack.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package cas;

import java.util.concurrent.atomic.AtomicReference;

public class NoBlockingStack<E> {
static class Node<E> {
final E item;
Node<E> next;
public Node(E item) { this.item = item; }
}

AtomicReference<Node<E>> head = new AtomicReference<Node<E>>();

public void push(E item) {
Node<E> newHead = new Node<E>(item);
Node<E> oldHead;
do {
oldHead = head.get();
newHead.next = oldHead;
} while (!head.compareAndSet(oldHead, newHead));
}
public E pop() {
Node<E> oldHead;
Node<E> newHead;
do {
oldHead = head.get();
if (oldHead == null)
return null;
newHead = oldHead.next;
} while (!head.compareAndSet(oldHead,newHead));
return oldHead.item;
}

}
11 changes: 11 additions & 0 deletions liuxin/knowledge-point/src/main/java/cas/Sequence.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package cas;

public class Sequence{

private int value;

public int next(){
return value ++;
}

}
20 changes: 20 additions & 0 deletions liuxin/knowledge-point/src/main/java/threadlocal/Context.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package threadlocal;
import java.util.HashMap;
import java.util.Map;

public class Context {

private static final ThreadLocal<String> txThreadLocal
= new ThreadLocal<String>();

public static void setTransactionID(String txID) {
txThreadLocal.set(txID);

}

public static String getTransactionId() {
return txThreadLocal.get();
}

}

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package threadlocal;

public class TransactionManager {
private static final ThreadLocal<String> context = new ThreadLocal<String>();

public static void startTransaction() {
// logic to start a transaction
// ...
String txID = null;
context.set(txID);
}

public static String getTransactionId() {
return context.get();
}

public static void endTransaction() {
// logic to end a transaction
// …
context.remove();
}
}
35 changes: 35 additions & 0 deletions liuxin/knowledge-point/src/main/java/threadpool/BlockingQueue.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package threadpool;
import java.util.LinkedList;
import java.util.List;

public class BlockingQueue {

private List queue = new LinkedList();
private int limit = 10;

public BlockingQueue(int limit) {
this.limit = limit;
}

public synchronized void enqueue(Object item) throws InterruptedException {
while (this.queue.size() == this.limit) {
wait();
}
if (this.queue.size() == 0) {
notifyAll();
}
this.queue.add(item);
}

public synchronized Object dequeue() throws InterruptedException {
while (this.queue.size() == 0) {
wait();
}
if (this.queue.size() == this.limit) {
notifyAll();
}

return this.queue.remove(0);
}

}
5 changes: 5 additions & 0 deletions liuxin/knowledge-point/src/main/java/threadpool/Task.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package threadpool;

public interface Task {
public void execute();
}
37 changes: 37 additions & 0 deletions liuxin/knowledge-point/src/main/java/threadpool/ThreadPool.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package threadpool;
import java.util.ArrayList;
import java.util.List;


public class ThreadPool {

private BlockingQueue taskQueue = null;
private List<WorkerThread> threads = new ArrayList<WorkerThread>();
private boolean isStopped = false;

public ThreadPool(int numOfThreads, int maxNumOfTasks){
taskQueue = new BlockingQueue(maxNumOfTasks);

for(int i=0; i<numOfThreads; i++){
threads.add(new WorkerThread(taskQueue));
}
for(WorkerThread thread : threads){
thread.start();
}
}

public synchronized void execute(Task task) throws Exception{
if(this.isStopped) throw
new IllegalStateException("ThreadPool is stopped");

this.taskQueue.enqueue(task);
}

public synchronized void stop(){
this.isStopped = true;
for(WorkerThread thread : threads){
thread.doStop();
}
}

}
33 changes: 33 additions & 0 deletions liuxin/knowledge-point/src/main/java/threadpool/WorkerThread.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package threadpool;


public class WorkerThread extends Thread {

private BlockingQueue taskQueue = null;
private boolean isStopped = false;

public WorkerThread(BlockingQueue queue){
taskQueue = queue;
}

public void run(){
while(!isStopped()){
try{
Task task = (Task) taskQueue.dequeue();
task.execute();
} catch(Exception e){
//log or otherwise report exception,
//but keep pool thread alive.
}
}
}

public synchronized void doStop(){
isStopped = true;
this.interrupt(); //break pool thread out of dequeue() call.
}

public synchronized boolean isStopped(){
return isStopped;
}
}
14 changes: 13 additions & 1 deletion liuxin/ood/ood-assignment/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,19 @@
<groupId>com.coderising</groupId>
<artifactId>ood-assignment</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
<packaging>jar</packaging>

<name>ood-assignment</name>
<url>http://maven.apache.org</url>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.coderising.dp.bridge;

public class GraphicLibrary1 {
public void draw_a_line(int x1,int y1,int x2,int y2){

}
public void draw_a_circle(int x,int y, int r){

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.coderising.dp.bridge;

public class GraphicLibrary2 {
public void drawLine(int x1,int x2,int y1,int y2){

}
public void drawCircle(int x,int y, int r){

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.coderising.dp.builder;

public class TagBuilder {
private TagNode rootNode;
private TagNode currentNode;
private TagNode parentNode;
public TagBuilder(String rootTagName){
rootNode = new TagNode(rootTagName);
currentNode = rootNode;
parentNode = null;
}

public TagBuilder addChild(String childTagName){
parentNode = this.currentNode;
this.currentNode = new TagNode(childTagName);
parentNode.add(currentNode);
return this;
}
public TagBuilder addSibling(String siblingTagName){

this.currentNode = new TagNode(siblingTagName);
parentNode.add(this.currentNode);
return this;

}
public TagBuilder setAttribute(String name, String value){
this.currentNode.setAttribute(name, value);
return this;
}
public TagBuilder setText(String value){
this.currentNode.setValue(value);
return this;
}
public String toXML(){
return this.rootNode.toXML();
}
}
Loading