Mercurial > hg > Database > jungle-sharp
comparison Main/jungle-main/data/list/headNode.cs @ 20:1f99e150f336
fix folder and add Object Mapper.
author | Kazuma Takeda |
---|---|
date | Thu, 15 Dec 2016 22:52:48 +0900 |
parents | |
children | f2ea780b3e80 |
comparison
equal
deleted
inserted
replaced
19:0865819106cf | 20:1f99e150f336 |
---|---|
1 using UnityEngine; | |
2 using System.Collections; | |
3 using System; | |
4 | |
5 public class headNode<T> : Node<T>{ | |
6 private readonly 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 if (num == 0) { | |
26 Node<T> newNode = new DefaultNode<T>(attribute, next); | |
27 return new headNode<T>(newNode); | |
28 } | |
29 Node<T> newNodes = next.add(currentNum + 1, num, attribute); | |
30 if (newNodes == null) { | |
31 return this; | |
32 } | |
33 return new headNode<T>(newNodes); | |
34 } | |
35 | |
36 public Node<T> addLast(T attribute) { | |
37 Node<T> node = next.addLast(attribute); | |
38 return new headNode<T>(node); | |
39 } | |
40 | |
41 public Node<T> delete(int currentNum, int deleteNum) { | |
42 if (currentNum == deleteNum) { | |
43 return new headNode<T>(this.next.getNext()); | |
44 } | |
45 | |
46 Node<T> newNode = next.delete(currentNum + 1, deleteNum); | |
47 if (newNode == null) { | |
48 return this; | |
49 } | |
50 return new headNode<T>(newNode); | |
51 } | |
52 | |
53 public Node<T> replaceNode(int currentNum, int num, T attribute) { | |
54 Node<T> nextNode = getNext(); | |
55 Node<T> newNode = nextNode.replaceNode(currentNum, num, attribute); | |
56 if (newNode == null) | |
57 return this; | |
58 return new headNode<T>(newNode); | |
59 } | |
60 | |
61 public int length() { | |
62 return next.length(); | |
63 } | |
64 | |
65 public T getAttribure() | |
66 { | |
67 throw new NotImplementedException(); | |
68 } | |
69 } |