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