Mercurial > hg > Database > jungle-sharp
view src/main/csharp/jp.ac.u-ryukyu.ie.cr/jungle-main/data/list/DefaultNode.cs @ 17:01a08cf4b2d9
Liq Files
author | Kazuma |
---|---|
date | Mon, 07 Nov 2016 01:05:24 +0900 |
parents | abe0c247f5a5 |
children |
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 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) { if (currentNum == num) { Node<T> newNode = new DefaultNode<T>(attribute, this.next); return new DefaultNode<T>(this.attribute, newNode); } Node<T> newNodes = next.add(currentNum + 1, num, attribute); if (newNodes == null) return null; return new DefaultNode<T>(this.attribute, newNodes); } 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(); } }