public void sortAdd(string name) { if (empty) { add(name); } else { bool doIt = true; for (int i = 0; i <= end; i++) { if (makeNameCode(getAt(i)) > makeNameCode(name)) { if (i == 0) { StrNode tmp = front; front = new StrNode(name); front.setNext(tmp); end++; } else { insertAfter(i - 1, name); } doIt = false; break; } } if (doIt) { add(name); } } }
public void insertAfter(int index, string value) { StrNode workingStrNode = getStrNodeAt(index); StrNode temp = workingStrNode.getNext(); StrNode newStrNode = new StrNode(value); newStrNode.setNext(temp); workingStrNode.setNext(newStrNode); end++; }
public void add(string d) { if (empty) { front = new StrNode(d); empty = false; } else { getStrNodeAt(end).setNext(new StrNode(d)); } end++; }
public void delAt(int index) { if (index == 0) { front = front.getNext(); } else { getStrNodeAt(index - 1).setNext(getStrNodeAt(index).getNext()); } end--; if (end == -1) { empty = true; } }
public void setNext(StrNode d) { next = d; }
public StrNode(string d) { data = d; next = null; }