コード例 #1
0
 private void removeFirstLocationFromList()
 {
     //remove the first location in list
     _FirstLocation = _CurrentLocation.NextLocation;
     _FirstLocation.PreviousLocation = null;
     _CurrentLocation = _FirstLocation;
 }
コード例 #2
0
 private void removeOnlyLocationFromList()
 {
     //if only one location in list remove it.
     _FirstLocation   = null;
     _CurrentLocation = null;
     _LastLocation    = null;
 }
コード例 #3
0
 private void removeLastLocationFromList()
 {
     //remove location from the end of the list
     _LastLocation = _CurrentLocation.PreviousLocation;
     _LastLocation.NextLocation = null;
     _CurrentLocation           = _LastLocation;
 }
コード例 #4
0
 public void Remove(MemoryLocation memLoc)
 {
     //public wrapper for removing a location
     _CurrentLocation = memLoc;
     removeCurrentLocation();
     renumberMemoryLocations();
 }
コード例 #5
0
 private void removeCurrentLocationFromList()
 {
     //remove location from the middle of the list
     _CurrentLocation.NextLocation.PreviousLocation = _CurrentLocation.PreviousLocation;
     _CurrentLocation.PreviousLocation.NextLocation = _CurrentLocation.NextLocation;
     _CurrentLocation = _CurrentLocation.PreviousLocation;
 }
コード例 #6
0
 private void addLocationToEndOfList(MemoryLocation n)
 {
     // add location to the end of the list
     n.PreviousLocation = _LastLocation;
     n.PreviousLocation.NextLocation = n;
     _LastLocation    = n;
     _CurrentLocation = n;
 }
コード例 #7
0
        public void AddAfter(int index, string wordValue)
        {
            //add given word after given index in the list.
            MemoryLocation newLoc = new MemoryLocation();

            newLoc.Word(wordValue);
            this.AddAfter(index, newLoc);
        }
コード例 #8
0
 private void addLocationToListAfterCurrentLocation(MemoryLocation n)
 {
     // add location to a specified location in the list
     n.PreviousLocation            = _CurrentLocation;
     n.NextLocation                = _CurrentLocation.NextLocation;
     _CurrentLocation.NextLocation = n;
     _CurrentLocation              = n;
 }
コード例 #9
0
ファイル: Pointer.cs プロジェクト: holmjona/ToyTronMVC
 public void Bind(MemoryLocation memLoc)
 {
     //This is done because the = operator for setting can not be overloaded.
     this.NextLocation     = memLoc.NextLocation;
     this.PreviousLocation = memLoc.PreviousLocation;
     this.ID       = memLoc.ID;
     this.HasError = memLoc.HasError;
     this.Word(memLoc.Word());
 }
コード例 #10
0
 private void addLocationToStartOfList(MemoryLocation n)
 {
     //add location to the start of the list
     if (_CurrentLocation == null)
     {
         _LastLocation = n;
     }
     _FirstLocation   = n;
     _CurrentLocation = n;
 }
コード例 #11
0
 public void moveToNextLocation()
 {
     //move along memory locations to next in list from current location
     if (_CurrentLocation != null)
     {
         if (_CurrentLocation.NextLocation != null)
         {
             _CurrentLocation = _CurrentLocation.NextLocation;
         }
     }
 }
コード例 #12
0
 public void moveToPreviousLocation()
 {
     //move along memory location to previous in list from the current location
     if (_CurrentLocation != null)
     {
         if (_CurrentLocation.PreviousLocation != null)
         {
             _CurrentLocation = _CurrentLocation.PreviousLocation;
         }
     }
 }
コード例 #13
0
 public void Add(MemoryLocation memLoc)
 {
     //public wrapper for adding a memory location
     try
     {
         this.addLocationToList(memLoc);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
コード例 #14
0
 public void AddAfter(int index, MemoryLocation memLoc)
 {
     //add location after a given index in the list
     try
     {
         _CurrentLocation = Locations(index);
         this.addLocationToList(memLoc);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
コード例 #15
0
        public int Count()
        {
            //returns the count of memory locations
            int            countInt = 0;
            MemoryLocation loc      = _FirstLocation;

            while (loc != null)
            {
                countInt += 1;
                loc       = loc.NextLocation;
            }
            return(countInt);
        }
コード例 #16
0
 private void addLocationToLocationList(MemoryLocation curLocation, ref System.Collections.Generic.List <MemoryLocation> alLocations)
 {
     //Add location to Generic List given
     if (curLocation == null)
     {
         //do nothing
     }
     else
     {
         alLocations.Add(curLocation);
         addLocationToLocationList(curLocation.NextLocation, ref alLocations);
     }
 }
コード例 #17
0
        public List <MemoryLocation> Locations()
        {
            //returns all memory locations in order
            List <MemoryLocation> retList = new List <MemoryLocation>();
            MemoryLocation        loc     = _FirstLocation;

            while (loc != null)
            {
                retList.Add(loc);
                loc = loc.NextLocation;
            }
            return(retList);
        }
コード例 #18
0
        private void renumberMemoryLocations()
        {
            //set the id of each location to proper numbers zero based index.
            MemoryLocation memLoc        = _FirstLocation;
            int            memLocCounter = 0;

            while (memLoc != null)
            {
                memLoc.ID      = memLocCounter;
                memLoc         = memLoc.NextLocation;
                memLocCounter += 1;
            }
            //_CurrentLocation = _LastLocation
        }
コード例 #19
0
 private void addLocationToArrayList(MemoryLocation curLocation, ref ArrayList alLocations)
 {
     //add locations to array list given
     if (curLocation == null)
     {
         //do nothing
     }
     else
     {
         string s = "";
         s += curLocation.Word().WordString;
         alLocations.Add(s);
         addLocationToArrayList(curLocation.NextLocation, ref alLocations);
     }
 }
コード例 #20
0
ファイル: ToyTronDAL.cs プロジェクト: holmjona/ToyTronMVC
        public int addInstuction(MemoryLocation myLoc, int programID)
        {
            //build connection
            SqlConnection conn = new SqlConnection(editonlyConnection);
            //build new command
            SqlCommand comm = new SqlCommand();
            //set command properties
            // ERROR: Not supported in C#: WithStatement

            int retInt;

            //open the connection to the database
            conn.Open();
            //executes the command that does not return a record set
            retInt = comm.ExecuteNonQuery();
            //close the connection to the database
            conn.Close();
            return(retInt);
        }
コード例 #21
0
 private void addLocationToList(MemoryLocation n)
 {
     //add memory location to list
     if (_FirstLocation == null)
     {
         addLocationToStartOfList(n);
     }
     else
     {
         if (_CurrentLocation.NextLocation != null)
         {
             addLocationToListAfterCurrentLocation(n);
         }
         else
         {
             addLocationToEndOfList(n);
         }
     }
     renumberMemoryLocations();
 }
コード例 #22
0
        public int Add(string wordValue)
        {
            //public wrappper for adding a word value
            MemoryLocation newLoc = new MemoryLocation();
            int            result;

            try
            {
                newLoc.Word(wordValue);

                result = 1;
            }
            catch
            {
                newLoc.Word("0000");
                newLoc.HasError = true;
                result          = -1;
            }
            this.Add(newLoc);
            return(result);
        }
コード例 #23
0
 //Private Sub advancePointer()
 //    _Pointer.Advance()
 //End Sub
 private void goToBranch(MemoryLocation storLoc)
 {
     //moves pointer to the new memory location
     _Pointer.Bind(storLoc);
     needToAdvancePointer = false;
 }