using UnityEngine; using System.Collections; using System; public class DefaultNode : Node { private readonly T attribute; private readonly Node next; //private TailNode tailNode; public DefaultNode(T attribute, Node next) { this.attribute = attribute; this.next = next; } public Node getNext() { return next; } public T getAttribute() { return attribute; } public Node addLast(T attribute) { Node node = next.addLast(attribute); return new DefaultNode(this.attribute, node); } public Node add(int currentNum, int num, T attribute) { if (currentNum == num) { Node newNode = new DefaultNode(attribute, this.next); return new DefaultNode(this.attribute, newNode); } Node newNodes = next.add(currentNum + 1, num, attribute); if (newNodes == null) return null; return new DefaultNode(this.attribute, newNodes); } public Node delete(int currentNum, int deleteNum) { if (currentNum == deleteNum) { return new DefaultNode (this.attribute, this.next.getNext ()); } Node newNode = next.delete (currentNum + 1, deleteNum); if (newNode == null) { return null; } return new DefaultNode(this.attribute, newNode); } public Node replaceNode(int currentNum, int num, T attribute) { if (currentNum == num) { return new DefaultNode(attribute, this.getNext()); } Node newNode = next.replaceNode(currentNum + 1, num, attribute); if (newNode == null) { return null; } return new DefaultNode(this.attribute, newNode); } public int length() { return next.length() + 1; } public T getAttribure() { throw new NotImplementedException(); } }