using UnityEngine; using System.Collections; using System; public class headNode : Node{ private 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) { Node newNode; if (num == 0) { newNode = new DefaultNode(attribute, next); return new headNode(newNode); } newNode = next.add(currentNum + 1, num, attribute); if (newNode == null) { return this; } return new headNode(newNode); } 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(); } }