Skip to content

Commit 9bedebf

Browse files
author
jossc
committed
1.添加操作栈
1 parent 50b7d76 commit 9bedebf

13 files changed

Lines changed: 228 additions & 2 deletions

File tree

.idea/compiler.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/java/com/Main.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
package com;
22

3+
import org.springframework.boot.autoconfigure.SpringBootApplication;
4+
35
/**
46
* @ClassName Main
57
* @Author chenzhuo
68
* @Version 1.0
79
* @Date 2019/11/24 10:06 下午
810
**/
11+
@SpringBootApplication
912
public class Main {
13+
public static void main(String[] args) {
14+
}
1015
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package com.datastructure.array;
2+
3+
/**
4+
* 数组测试
5+
* 目的
6+
* 验证数组是一片连续内存
7+
*
8+
* @ClassName ArrayTest
9+
* @Author chenzhuo
10+
* @Version 1.0
11+
* @Date 2019/12/5 12:19 下午
12+
**/
13+
public class ArrayTest {
14+
15+
public static void main(String[] args) {
16+
int[] ints = new int[]{
17+
Integer.MAX_VALUE,
18+
Integer.MAX_VALUE,
19+
Integer.MAX_VALUE,
20+
Integer.MAX_VALUE,
21+
Integer.MAX_VALUE,
22+
Integer.MAX_VALUE,
23+
Integer.MAX_VALUE};
24+
System.out.println(ints.getClass());
25+
System.out.println(ints.length);
26+
System.out.println(ints.hashCode());
27+
28+
int[] newInt = new int[10];
29+
System.out.println(newInt.length);
30+
}
31+
}
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
package com.datastructure.queue;
2+
3+
/**
4+
* Lru Base Linked list
5+
*
6+
* @ClassName LRUBaseLinkedList
7+
* @Author chenzhuo
8+
* @Version 1.0
9+
* @Date 2019/12/5 1:19 下午
10+
**/
11+
public class LruBaseLinkedList<T> {
12+
13+
/**
14+
* 默认长度
15+
*/
16+
private final static Integer DEFAULT_CAPACITY = 10;
17+
18+
/**
19+
* 头结点
20+
*/
21+
private Node<T> headNode;
22+
23+
/**
24+
* 长度
25+
*/
26+
private Integer length;
27+
28+
/**
29+
* 链表容量
30+
*/
31+
private Integer capacity;
32+
33+
public LruBaseLinkedList() {
34+
this.headNode = new Node<>();
35+
this.capacity = DEFAULT_CAPACITY;
36+
this.length = 0;
37+
}
38+
39+
public LruBaseLinkedList(Integer capacity) {
40+
this.capacity = capacity;
41+
}
42+
43+
/**
44+
* 添加元素
45+
*
46+
* @param data 元素
47+
*/
48+
public void add(T data) {
49+
50+
}
51+
52+
private class Node<T> {
53+
54+
private T element;
55+
56+
private Node next;
57+
58+
public Node(T element) {
59+
this.element = element;
60+
}
61+
62+
public Node(T element, Node next) {
63+
this.element = element;
64+
this.next = next;
65+
}
66+
67+
public Node() {
68+
this.next = null;
69+
}
70+
71+
public T getElement() {
72+
return element;
73+
}
74+
75+
public void setElement(T element) {
76+
this.element = element;
77+
}
78+
79+
public Node getNext() {
80+
return next;
81+
}
82+
83+
public void setNext(Node next) {
84+
this.next = next;
85+
}
86+
}
87+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/**
2+
* @ClassName package-info
3+
* @Author chenzhuo
4+
* @Version 1.0
5+
* @Date 2019/12/5 12:43 下午
6+
**/
7+
package com.datastructure.queue;
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package com.datastructure.stack;
2+
3+
/**
4+
* 栈数组
5+
* 用数组实现栈 先进出,后进先出
6+
*
7+
* @ClassName StackArray
8+
* @Author chenzhuo
9+
* @Version 1.0
10+
* @Date 2019/12/6 12:45 下午
11+
**/
12+
public class StackArray {
13+
14+
private volatile int count;
15+
16+
private int len;
17+
18+
private String[] arrays;
19+
20+
21+
public StackArray(int len) {
22+
this.len = len;
23+
this.arrays = new String[len];
24+
this.count = 0;
25+
}
26+
27+
public boolean addElement(String value) {
28+
if (len == count) {
29+
return false;
30+
}
31+
arrays[count] = value;
32+
++count;
33+
return true;
34+
}
35+
36+
public String pop() {
37+
if (count == 0) {
38+
return null;
39+
}
40+
String value = arrays[count - 1];
41+
--count;
42+
return value;
43+
}
44+
45+
public static void main(String[] args) {
46+
47+
}
48+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* 栈
3+
* @ClassName package-info
4+
* @Author chenzhuo
5+
* @Version 1.0
6+
* @Date 2019/12/6 12:44 下午
7+
**/
8+
package com.datastructure.stack;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,30 @@
11
package com.jdk8.invokedynamic;
22

3+
import java.lang.invoke.*;
4+
5+
import static java.lang.invoke.MethodHandles.*;
6+
37
/**
48
* @ClassName Circuit
59
* @Author chenzhuo
610
* @Version 1.0
711
* @Date 2019/12/2 10:36 下午
812
**/
913
public class Circuit {
14+
public static void startRace(Object obj) {
15+
/* Lookup lookup =new Lookup(obj.getClass());
16+
boosStrap();*/
17+
}
18+
19+
public static void main(String[] args) {
20+
startRace(new Horse());
21+
}
22+
23+
public static CallSite boosStrap(Lookup l, String name, MethodType callSiteTyp) throws NoSuchMethodException, IllegalAccessException {
24+
MethodHandle mh = l.findVirtual(Horse.class, name, MethodType.methodType(void.class));
25+
return new ConstantCallSite(mh.asType(callSiteTyp));
26+
27+
}
28+
29+
1030
}

src/main/java/com/jdk8/invokedynamic/Deer.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,8 @@
77
* @Date 2019/12/2 10:36 下午
88
**/
99
public class Deer {
10+
public void race() {
11+
System.out.println("Deer.race()");
12+
}
13+
1014
}

src/main/java/com/jdk8/invokedynamic/Horse.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,7 @@
77
* @Date 2019/12/2 10:35 下午
88
**/
99
public class Horse {
10+
public void race() {
11+
System.out.println("Horse.race()");
12+
}
1013
}

0 commit comments

Comments
 (0)