package arrays.file;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Random;
public class ConcludeCombinationSortWrite {
/**
* 大数据排序合并
*
* @param args
*/
public static void main(String[] args) throws IOException {
// 写入文件的路径
String filePath = "D:\\456";
// 切分文件的路径
String sqlitFilePath = "D:\\456\\123";
//数据的个数
int CountNumbers=10000000;
//子文件的个数
int CountFile=10;
//精度
int countAccuracy=30*CountFile;
long startNumber=System.currentTimeMillis();
// 写入大数据文件
......
package arrays.file;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StringReader;
import java.io.Writer;
public class CreateFile {
public static void main(String[] args) {
// readerFile("E:/workspace6/Arrays/src/myArray/Nodes.java");
// readerFileToo();
//writeInMemroy();
writeFile2();
}
// 经典读取数据一
public static String readerFile() {
// E:/workspace6/Arrays/src/myArray/Nodes.java
String s, s2 = "";
try {
BufferedReader in = new BufferedReader(new FileReader
("E:/workspace6/Arrays/src/myArray/Nodes.java"));
try {
&nb ......
package arrays.myArray;
public class BinaryTree {
private Node root;
// 添加数据
public void add(int data) {
// 递归调用
if (null == root)
root = new Node(data, null, null);
else
addTree(root, data);
}
private void addTree(Node rootNode, int data) {
// 添加到左边
if (rootNode.data > data) {
if (rootNode.left == null)
rootNode.left = new Node(data, null, null);
else
addTree(rootNode.left, data);
} else {
// 添加到右边
if (rootNode.right == null)
rootNode.right = new Node(data, null, null);
else
addTree(rootNode.right, data);
}
}
// 查询数据
public void show() {
showTree(root);
}
priv ......
package arrays.myArray;
public class MyArrayList {
private Object[] arrObj = new Object[3];
private int size = 0;
// 长度
public int size() {
return size;
}
// insert
public void add(Object obj) {
add(size,obj);
}
// update
// 把前面的往后移动
public void add(int index, Object obj) {
if(size==arrObj.length){
Object[] temp=new Object[size*2];
for(int i=0;i<arrObj.length;i++){
temp[i]=arrObj[i];
}
arrObj=temp;
}
//从前往后
for (int i =size; i>index ; i--) {
arrObj[i] = arrObj[i-1];
}
arrObj[index]=obj;
size++;
}
// delete
// 把后面的往前移动
public void remove(int index) {
size--;
for (int i =index;i<size; i+ ......
package arrays.myArray;
public class MyLinkedList {
private int size = 0;
private Node1 head = null;
// 添加
public void add(Object obj) {
add(size, obj);
}
// 修改
public void add(int index, Object obj) {
if (null == head) {
head = new Node1(obj, null);
} else {
if (0 == index) {
head = new Node1(obj, head);
} else {
Node1 temp = head;
for (int i = 0; i < index - 1; i++) {
temp = temp.next;
}
temp.next = new Node1(obj, temp.next);
}
}
size++;
}
// 移除
public void remove(int index) {
if (0 == index) {
head = head.next;
} else {
Node1 temp = head;
&nbs ......
package arrays.myArray;
public class SortArr {
public static void main(String[] args) {
int[] arrInt = { 4, 7, 8, 5, 6, 3, 2, 3, 4 };
maoPaoSort(arrInt);
print("冒泡排序:", arrInt);
arrInt = new int[]{ 4, 7, 8, 5, 6, 3, 2, 3, 4 };
insertSort(arrInt);
print("插入排序:", arrInt);
arrInt = new int[]{ 4, 7, 8, 5, 6, 3, 2, 3, 4 };
checkSort(arrInt);
print("选择排序:", arrInt);
}
// 冒泡排序
private static void maoPaoSort(int[] arrInt) {
int temp = 0;
for (int i = 0; i < arrInt.length; i++) {
for (int j = 0; j < arrInt.length - 1; j++) {
if (arrInt[i] < arrInt[j]) {
temp = arrInt[i];
arrInt[i] = arrInt[j];
arrInt[j] = temp;
}
}
&nbs ......