質問編集履歴
1
新しく、BinSearchTreeNodeのファイルを追加しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -555,3 +555,107 @@
|
|
555
555
|
|
556
556
|
|
557
557
|
```
|
558
|
+
|
559
|
+
|
560
|
+
|
561
|
+
```java
|
562
|
+
|
563
|
+
package genericSearch;
|
564
|
+
|
565
|
+
|
566
|
+
|
567
|
+
import java.util.Map;
|
568
|
+
|
569
|
+
|
570
|
+
|
571
|
+
//Kはデータのキーの型,Vはデータの値の型
|
572
|
+
|
573
|
+
public class BinSearchTreeNode<K,V> {
|
574
|
+
|
575
|
+
private Map.Entry<K,V> data ;
|
576
|
+
|
577
|
+
private BinSearchTreeNode<K,V> left, right ;
|
578
|
+
|
579
|
+
|
580
|
+
|
581
|
+
//コンストラクタ
|
582
|
+
|
583
|
+
public BinSearchTreeNode(Map.Entry<K,V> data, BinSearchTreeNode<K,V> left,
|
584
|
+
|
585
|
+
BinSearchTreeNode<K,V> right) {
|
586
|
+
|
587
|
+
this.data = data ;
|
588
|
+
|
589
|
+
this.left = left ;
|
590
|
+
|
591
|
+
this.right = right ;
|
592
|
+
|
593
|
+
}
|
594
|
+
|
595
|
+
|
596
|
+
|
597
|
+
//葉を作るためのコンストラクタ
|
598
|
+
|
599
|
+
public BinSearchTreeNode(Map.Entry<K,V> data) {
|
600
|
+
|
601
|
+
this(data, null, null) ;
|
602
|
+
|
603
|
+
}
|
604
|
+
|
605
|
+
|
606
|
+
|
607
|
+
//葉か否かを判定するメソッド
|
608
|
+
|
609
|
+
public boolean isLeaf() {
|
610
|
+
|
611
|
+
return left == null && right == null ;
|
612
|
+
|
613
|
+
}
|
614
|
+
|
615
|
+
|
616
|
+
|
617
|
+
|
618
|
+
|
619
|
+
//accessorメソッド
|
620
|
+
|
621
|
+
public Map.Entry<K,V> getData() {
|
622
|
+
|
623
|
+
return data ;
|
624
|
+
|
625
|
+
}
|
626
|
+
|
627
|
+
public BinSearchTreeNode<K,V> getLeft() {
|
628
|
+
|
629
|
+
return left ;
|
630
|
+
|
631
|
+
}
|
632
|
+
|
633
|
+
public BinSearchTreeNode<K,V> getRight() {
|
634
|
+
|
635
|
+
return right ;
|
636
|
+
|
637
|
+
}
|
638
|
+
|
639
|
+
public void setData(Map.Entry<K,V> data) {
|
640
|
+
|
641
|
+
this.data = data ;
|
642
|
+
|
643
|
+
}
|
644
|
+
|
645
|
+
public void setLeft(BinSearchTreeNode<K,V> left) {
|
646
|
+
|
647
|
+
this.left = left ;
|
648
|
+
|
649
|
+
}
|
650
|
+
|
651
|
+
public void setRight(BinSearchTreeNode<K,V> right) {
|
652
|
+
|
653
|
+
this.right = right ;
|
654
|
+
|
655
|
+
}
|
656
|
+
|
657
|
+
}
|
658
|
+
|
659
|
+
|
660
|
+
|
661
|
+
```
|