Mercurial > hg > Database > jungle-sharp
comparison src/main/csharp/jp.ac.u-ryukyu.ie.cr/jungle/data/list/headNode.cs @ 0:dec15de2c6ff
first commit
author | Kazuma |
---|---|
date | Tue, 21 Jun 2016 17:11:12 +0900 |
parents | |
children | 79da77797f7e |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:dec15de2c6ff |
---|---|
1 using UnityEngine; | |
2 using System.Collections; | |
3 using System; | |
4 | |
5 public class headNode<T> : Node<T>{ | |
6 private Node<T> next; | |
7 | |
8 public headNode(){ | |
9 this.next = new TailNode<T> (); | |
10 } | |
11 | |
12 public headNode(Node<T> next){ | |
13 this.next = next; | |
14 } | |
15 | |
16 public Node<T> getNext(){ | |
17 return next; | |
18 } | |
19 | |
20 public T getAttribute(){ | |
21 return default(T); | |
22 } | |
23 | |
24 public Node<T> add(int currentNum, int num, T attribute) { | |
25 Node<T> newNode; | |
26 if (num == 0) { | |
27 newNode = new DefaultNode<T>(attribute, next); | |
28 return new headNode<T>(newNode); | |
29 } | |
30 newNode = next.add(currentNum + 1, num, attribute); | |
31 if (newNode == null) { | |
32 return this; | |
33 } | |
34 return new headNode<T>(newNode); | |
35 } | |
36 | |
37 public Node<T> addLast(T attribute) { | |
38 Node<T> node = next.addLast(attribute); | |
39 return new headNode<T>(node); | |
40 } | |
41 | |
42 public Node<T> delete(int currentNum, int deleteNum) { | |
43 if (currentNum == deleteNum) { | |
44 return new headNode<T>(this.next.getNext()); | |
45 } | |
46 | |
47 Node<T> newNode = next.delete(currentNum + 1, deleteNum); | |
48 if (newNode == null) { | |
49 return this; | |
50 } | |
51 return new headNode<T>(newNode); | |
52 } | |
53 | |
54 public Node<T> replaceNode(int currentNum, int num, T attribute) { | |
55 Node<T> nextNode = getNext(); | |
56 Node<T> newNode = nextNode.replaceNode(currentNum, num, attribute); | |
57 if (newNode == null) | |
58 return this; | |
59 return new headNode<T>(newNode); | |
60 } | |
61 | |
62 public int length() { | |
63 return next.length(); | |
64 } | |
65 | |
66 public T getAttribure() | |
67 { | |
68 throw new NotImplementedException(); | |
69 } | |
70 } |