예제 #1
0
        public CircList(ICollection <CircListBeg> col) //
        {
            CircListBeg help = new CircListBeg();

            First = help;
            foreach (CircListBeg entry in col)
            {
                help.Value = entry.Value;
                help.Key   = entry.Key;
                help.Next  = new CircListBeg();
                help       = help.Next;
            }
            //help = First;
        }
예제 #2
0
 public void Add(CircListBeg entry)
 {
     if (First != null)
     {
         CircListBeg help = this.SearchKey(Count - 1);
         help.Next  = entry;
         entry.Next = First;
         entry.Key  = help.Key + 1;
     }
     else
     {
         First      = entry;
         First.Key  = 0;
         First.Next = First;
     }
 }
예제 #3
0
 public override string ToString()
 {
     if (First != null)
     {
         string      ans  = "";
         CircListBeg help = First;
         ans += First.ToString() + " ";
         help = help.Next;
         while (help.Key != First.Key)
         {
             ans += help.ToString() + " ";
             help = help.Next;
         }
         return(ans);
     }
     else
     {
         return("Список пуст");
     }
 }
예제 #4
0
 public void Remove(CircListBeg entry)
 {
     if (First != null)
     {
         CircListBeg help = First;
         if (help.Value != entry.Value)
         {
             CircListBeg last = help;
             help = help.Next;
             while (help.Key != First.Key)
             {
                 if (help.Value == entry.Value)
                 {
                     last.Next = help.Next;
                     for (int i = help.Key; i < Count - 1; i++)
                     {
                         help     = help.Next;
                         help.Key = i;
                     }
                     break;
                 }
                 else
                 {
                     last = help;
                     help = help.Next;
                 }
             }
         }
         else
         {
             SearchKey(Count - 1).Next = help.Next;
             First     = help.Next;
             First.Key = 0;
             for (int i = 0; i < Count - 1; i++)
             {
                 help     = help.Next;
                 help.Key = i;
             }
         }
     }
 }
예제 #5
0
        public CircListBeg SearchKey(int key)
        {
            CircListBeg help = First;

            if (key == help.Key)
            {
                return(help);
            }
            help = help.Next;
            while (help.Key != First.Key)
            {
                if (key == help.Key)
                {
                    return(help);
                }
                else
                {
                    help = help.Next;
                }
            }
            return(null);
        }
예제 #6
0
 public CircList(CircListBeg first) //с парам.
 {
     First = first;
 }
예제 #7
0
 public CircListBeg(int value)
 {
     Value = value;
     Next  = null;
 }
예제 #8
0
 public CircListBeg()
 {
     Key   = 0;
     Value = 0;
     Next  = null;
 }