Mercurial > hg > Database > jungle-sharp
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/csharp/jp.ac.u-ryukyu.ie.cr/jungle/data/list/headNode.cs Tue Jun 21 17:11:12 2016 +0900 @@ -0,0 +1,70 @@ +using UnityEngine; +using System.Collections; +using System; + +public class headNode<T> : Node<T>{ + private Node<T> next; + + public headNode(){ + this.next = new TailNode<T> (); + } + + public headNode(Node<T> next){ + this.next = next; + } + + public Node<T> getNext(){ + return next; + } + + public T getAttribute(){ + return default(T); + } + + public Node<T> add(int currentNum, int num, T attribute) { + Node<T> newNode; + if (num == 0) { + newNode = new DefaultNode<T>(attribute, next); + return new headNode<T>(newNode); + } + newNode = next.add(currentNum + 1, num, attribute); + if (newNode == null) { + return this; + } + return new headNode<T>(newNode); + } + + public Node<T> addLast(T attribute) { + Node<T> node = next.addLast(attribute); + return new headNode<T>(node); + } + + public Node<T> delete(int currentNum, int deleteNum) { + if (currentNum == deleteNum) { + return new headNode<T>(this.next.getNext()); + } + + Node<T> newNode = next.delete(currentNum + 1, deleteNum); + if (newNode == null) { + return this; + } + return new headNode<T>(newNode); + } + + public Node<T> replaceNode(int currentNum, int num, T attribute) { + Node<T> nextNode = getNext(); + Node<T> newNode = nextNode.replaceNode(currentNum, num, attribute); + if (newNode == null) + return this; + return new headNode<T>(newNode); + } + + public int length() { + return next.length(); + } + + public T getAttribure() + { + throw new NotImplementedException(); + } +}