Esempio n. 1
0
        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);
                }
            }
        }
Esempio n. 2
0
        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++;
        }
Esempio n. 3
0
        public void add(string d)
        {
            if (empty)
            {
                front = new StrNode(d);
                empty = false;
            }
            else
            {
                getStrNodeAt(end).setNext(new StrNode(d));
            }

            end++;
        }
Esempio n. 4
0
        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;
            }
        }
Esempio n. 5
0
 public void setNext(StrNode d)
 {
     next = d;
 }
Esempio n. 6
0
 public StrNode(string d)
 {
     data = d;
     next = null;
 }