comparison src/tree/BTreeMap.java @ 0:a9cb12a7f995

hg init
author misaka
date Wed, 06 Jul 2011 15:19:52 +0900
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:a9cb12a7f995
1 package tree;
2
3 import java.util.ArrayList;
4 import java.util.Iterator;
5
6 public class BTreeMap<K extends Comparable<K>,V> implements Map<K,V>
7 {
8 private final int order;
9
10 public BTreeMap(int order)
11 {
12 this.order = order;
13 }
14
15 @Override
16 public void put(K _key, V _value)
17 {
18 }
19
20 @Override
21 public V get(K _key)
22 {
23 return null;
24 }
25
26 public V remove(K _key)
27 {
28 return null;
29 }
30
31 private static abstract class Node<K extends Comparable<K>,V>
32 {
33 @Override
34 public abstract String toString();
35 }
36
37 private class Link<K extends Comparable<K>,V>
38 {
39 public K key;
40 public Node<K,V> node;
41
42 public Link(K key,Node<K,V> node)
43 {
44 this.key = key;
45 this.node = node;
46 }
47 }
48
49 private class Bucket<K extends Comparable<K>,V> extends Node<K,V>
50 {
51 private final int order;
52 private ArrayList<Link<K,V>> children;
53
54 public Bucket(int order)
55 {
56 this.order = order;
57 children = new ArrayList<Link<K,V>>(this.order+2);
58 }
59
60 @Override
61 public String toString()
62 {
63 return "bucket";
64 }
65 }
66
67 private class Leaf<K extends Comparable<K>,V> extends Node<K,V>
68 {
69 public K key;
70 public V value;
71
72 public Leaf(K key,V value)
73 {
74 this.key = key;
75 this.value = value;
76 }
77
78 @Override
79 public String toString()
80 {
81 return String.format("key = %s , value = %s",key,value);
82 }
83 }
84 }