diff --git a/pom.xml b/pom.xml
index 5f0c536..6b6dad7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -21,6 +21,16 @@
+
+ org.springframework.boot
+ spring-boot-starter-web
+ 1.5.10.RELEASE
+
+
+ org.mybatis.spring.boot
+ mybatis-spring-boot-starter
+ 1.3.0
+
diff --git a/src/main/java/Hello.java b/src/main/java/Hello.java
index 40598ca..57f9fea 100644
--- a/src/main/java/Hello.java
+++ b/src/main/java/Hello.java
@@ -1,5 +1,28 @@
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
+import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
public class Hello {
+
public static void main(String[] args) {
+ ClassPathXmlApplicationContext ac = new ClassPathXmlApplicationContext("beans.xml");
+ String username = System.getenv("USERNAME");
+ System.out.println(username);
+ Hello hello = ac.getBean(Hello.class);
+ System.out.println(hello);
+ String a = ac.getEnvironment().getProperty("a");
+ System.out.println(a);
+ }
+}
+
+
+class MyBeanFactoryPostProcess implements BeanFactoryPostProcessor{
+ @Override
+ public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
+ BeanDefinition hello = beanFactory.getBeanDefinition("Hello");
+// hello.set
System.out.println(12);
}
}
diff --git a/src/main/java/com/A.java b/src/main/java/com/A.java
new file mode 100644
index 0000000..aae8e0d
--- /dev/null
+++ b/src/main/java/com/A.java
@@ -0,0 +1,14 @@
+package com;
+
+
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Import;
+import org.springframework.context.annotation.ImportResource;
+import org.springframework.context.annotation.PropertySource;
+import org.springframework.stereotype.Component;
+
+@Component
+@PropertySource(value = {"a.properties"})
+public class A {
+
+}
diff --git a/src/main/java/com/B.java b/src/main/java/com/B.java
new file mode 100644
index 0000000..2397fb6
--- /dev/null
+++ b/src/main/java/com/B.java
@@ -0,0 +1,8 @@
+package com;
+
+
+import org.springframework.context.annotation.ImportResource;
+
+//@ImportResource(locations = {"bean.xml"})
+public class B {
+}
diff --git a/src/main/resources/a.properties b/src/main/resources/a.properties
new file mode 100644
index 0000000..e6a001e
--- /dev/null
+++ b/src/main/resources/a.properties
@@ -0,0 +1 @@
+a=12
\ No newline at end of file
diff --git a/src/test/java/zuolaos/jichuban/Code03_链表反转.java b/src/test/java/zuolaos/jichuban/Code03_链表反转.java
index dc8c3bd..ed1853a 100644
--- a/src/test/java/zuolaos/jichuban/Code03_链表反转.java
+++ b/src/test/java/zuolaos/jichuban/Code03_链表反转.java
@@ -1,5 +1,8 @@
package zuolaos.jichuban;
+import java.util.ArrayList;
+import java.util.List;
+
public class Code03_链表反转 {
@@ -12,58 +15,149 @@ public class Code03_链表反转 {
}
}
+ private static class NewNode {
+ int value;
+ NewNode left;
+ NewNode right;
+
+ public NewNode(int value) {
+ this.value = value;
+ }
+ }
+
private static class DoubleNode {
int value;
DoubleNode next;
DoubleNode last;
+
public DoubleNode(int value) {
this.value = value;
}
}
public static void main(String[] args) {
-
- Node node = new Node(1);
- node.next = new Node(2);
- node.next.next = new Node(3);
- Node newNode = reverNode(node);
- System.out.println(newNode.value);
+ NewNode newNode = new NewNode(1);
+ newNode.left = new NewNode(2);
+ newNode.right = new NewNode(3);
+ newNode.left.left = new NewNode(2);
+ newNode.left.right = new NewNode(2);
+ newNode.right.left = new NewNode(2);
+ newNode.right.right = new NewNode(2);
+ newNode.right.right = new NewNode(2);
+ newNode.right.right.right = new NewNode(2);
+ List> cengji = cengji(newNode);
+ System.out.println(cengji);
+ Integer integer = new Integer(1);
+ Integer integer2 = new Integer(1);
+ System.out.println(integer.hashCode()==integer2.hashCode());
+ }
- DoubleNode doubleNode = new DoubleNode(1);
- DoubleNode doubleNode2 = new DoubleNode(2);
- DoubleNode doubleNode3 = new DoubleNode(3);
- doubleNode.next = doubleNode2;
- doubleNode.next.next = doubleNode3;
- doubleNode3.last=doubleNode2;
- doubleNode3.last.last=doubleNode;
- DoubleNode newNode2 = reverDoubleNode(doubleNode);
- System.out.println(newNode2.value);
+ public static List> cengji(NewNode node) {
+ List> ans = new ArrayList<>();
+ List nodes = new ArrayList<>();
+ nodes.add(node);
+ process(nodes, ans);
+ return ans;
+ }
+ private static void process(List nodes, List> ans) {
+ if (nodes == null || nodes.size() == 0) {
+ return;
+ }
+ List values = new ArrayList<>();
+ List newNodes = new ArrayList<>();
+ for (NewNode node : nodes) {
+ values.add(node.value);
+ if (node.left != null) {
+ newNodes.add(node.left);
+ }
+ if (node.right != null) {
+ newNodes.add(node.right);
+ }
+ }
+ ans.add(values);
+ process(newNodes, ans);
}
+
+ //双向链表迭代
private static DoubleNode reverDoubleNode(DoubleNode head) {
- DoubleNode pre=null;
- DoubleNode next=null;
- while (head!=null){
- next=head.next;
- head.next=pre;
- head.last=next;
- pre=head;
- head=next;
+ DoubleNode pre = null;
+ DoubleNode next = null;
+ while (head != null) {
+ next = head.next;
+ head.next = pre;
+ head.last = next;
+ pre = head;
+ head = next;
}
return pre;
}
+ //双向链表递归
+ private static DoubleNode reverDoubleNode2(DoubleNode head) {
+ if (head == null || head.next == null) {
+ head.last = null;
+ return head;
+ }
+ DoubleNode newhead = reverDoubleNode2(head.next);
+ head.next.next = head;
+ head.last = head.next;
+ return newhead;
+
+ }
+
+ //单向链表迭代
private static Node reverNode(Node head) {
- Node pre=null;
- Node next=null;
- while (head!=null){
- next=head.next;
- head.next=pre;
- pre=head;
- head=next;
+ Node pre = null;
+ Node next = null;
+ while (head != null) {
+ next = head.next;
+ head.next = pre;
+ pre = head;
+ head = next;
}
return pre;
}
+
+ //单向链表递归
+ private static Node reverNode2(Node node) {
+ if (node == null || node.next == null) {
+ return node;
+ }
+ Node head = reverNode2(node.next);
+ node.next.next = node;
+ node.next = null;
+ return head;
+ }
+
+ //删除对应值的链表
+ private static Node removeNodeOfValue(Node node, int num) {
+ //先确定头
+ while (node != null) {
+ if (node.value != num) {
+ break;
+ }
+ node = node.next;
+ }
+
+ Node pre = node;
+ Node cur = node;
+
+ while (cur != null) {
+ if (cur.value == num) {
+ pre.next = cur.next;
+ } else {
+ pre = cur;
+ }
+ cur = cur.next;
+ }
+
+ return node;
+
+
+ }
+
+
}
diff --git a/src/test/java/zuolaos/jichuban/Code04_链表实现队列.java b/src/test/java/zuolaos/jichuban/Code04_链表实现队列.java
index 8b8123c..2a2edf7 100644
--- a/src/test/java/zuolaos/jichuban/Code04_链表实现队列.java
+++ b/src/test/java/zuolaos/jichuban/Code04_链表实现队列.java
@@ -1,6 +1,6 @@
package zuolaos.jichuban;
-public class Code04_链表实现队列 {
+public class Code04_链表实现队列 {
private static class Node {
V value;
diff --git a/src/test/java/zuolaos/jichuban/Code11_异或运算.java b/src/test/java/zuolaos/jichuban/Code11_异或运算.java
new file mode 100644
index 0000000..44494dd
--- /dev/null
+++ b/src/test/java/zuolaos/jichuban/Code11_异或运算.java
@@ -0,0 +1,47 @@
+package zuolaos.jichuban;
+
+public class Code11_异或运算 {
+
+
+ //某个数出现奇数次 其他出现偶数次
+ public static void m1(int[] arr) {
+ int ans = 0;
+ for (int i = 0; i < arr.length; i++) {
+ ans ^= arr[i];
+ }
+ System.out.println(ans);
+ }
+
+ //某两个数出现奇数次 其他出现偶数次
+ public static void m3(int[] arr) {
+ int ans = 0;
+ for (int num : arr) {
+ ans ^= num;
+ }
+ int rightOne = ans & (-ans);
+ int ans2 = 0;
+ for (int num : arr) {
+ if ((num & rightOne) != 0) {
+ ans2 ^= num;
+ }
+ }
+ System.out.println(ans2);
+ System.out.println(ans ^ ans2);
+ }
+
+ //某个数出现了K次 其他数出现了M次
+ public static void m2(int[] arr, int k, int m) {
+ int[] bits = new int[32];
+ for (int num : arr) {
+ for (int i = 0; i < 32; i++) {
+ bits[i] += (num >> i) & 1;
+ }
+ }
+ int ans = 0;
+ for (int i = 0; i < bits.length; i++) {
+ if (bits[i] % m != 0) {
+ ans |= (1 << i);
+ }
+ }
+ }
+}
diff --git a/src/test/java/zuolaos/jichuban/Code11_栈和队列.java b/src/test/java/zuolaos/jichuban/Code11_栈和队列.java
new file mode 100644
index 0000000..3e7409f
--- /dev/null
+++ b/src/test/java/zuolaos/jichuban/Code11_栈和队列.java
@@ -0,0 +1,20 @@
+package zuolaos.jichuban;
+
+import java.util.Stack;
+import java.util.TreeMap;
+
+public class Code11_栈和队列 {
+
+
+}
+
+class TowStacktToQueue{
+
+
+ Stack push=new Stack<>();
+ Stack poll=new Stack<>();
+
+ public void offer(){
+ TreeMap