Mercurial > hg > Database > jungle-sharp
view src/main/csharp/jp.ac.u-ryukyu.ie.cr/jungle/data/list/DefaultNode.cs @ 4:79da77797f7e
list/List.cs fix, and not work addLast
author | Kazuma |
---|---|
date | Mon, 04 Jul 2016 03:50:34 +0900 |
parents | a3af05a061b4 |
children | 0428c8888abf |
line wrap: on
line source
using UnityEngine; using System.Collections; using System; public class DefaultNode<T> : Node<T> { private readonly T attribute; private readonly Node<T> next; //private TailNode<T> tailNode; public DefaultNode(T attribute, Node<T> next) { this.attribute = attribute; this.next = next; } // public DefaultNode(Node<T> attribute1, TailNode<T> tailNode) // { // this.attribute1 = attribute1; // this.tailNode = tailNode; // } public Node<T> getNext() { return next; } public T getAttribute() { return attribute; } public Node<T> addLast(T attribute) { Node<T> node = next.addLast(attribute); return new DefaultNode<T>(this.attribute, node); } public Node<T> add(int currentNum, int num, T attribute) { Node<T> newNode; if (currentNum == num) { newNode = new DefaultNode<T>(attribute, this.next); return new DefaultNode<T>(this.attribute, newNode); } newNode = next.add(currentNum + 1, num, attribute); if (newNode == null) return null; return new DefaultNode<T>(this.attribute, newNode); } public Node<T> delete(int currentNum, int deleteNum) { if (currentNum == deleteNum) { return new DefaultNode<T> (this.attribute, this.next.getNext ()); } Node<T> newNode = next.delete (currentNum + 1, deleteNum); if (newNode == null) { return null; } return new DefaultNode<T>(this.attribute, newNode); } public Node<T> replaceNode(int currentNum, int num, T attribute) { if (currentNum == num) { return new DefaultNode<T>(attribute, this.getNext()); } Node<T> newNode = next.replaceNode(currentNum + 1, num, attribute); if (newNode == null) { return null; } return new DefaultNode<T>(this.attribute, newNode); } public int length() { return next.length() + 1; } public T getAttribure() { throw new NotImplementedException(); } }