Reset() private method

private Reset ( Regex regex, string text, int textbeg, int textend, int textstart ) : void
regex Regex
text string
textbeg int
textend int
textstart int
return void
Example #1
0
        /*
         * Initializes all the data members that are used by Go()
         */
        private void InitMatch()
        {
            // Use a hashtable'ed Match object if the capture numbers are sparse

            if (_runmatch == null)
            {
                if (_runregex._caps != null)
                {
                    _runmatch = new MatchSparse(_runregex, _runregex._caps, _runregex._capsize, _runtext, _runtextbeg, _runtextend - _runtextbeg, _runtextstart);
                }
                else
                {
                    _runmatch = new Match(_runregex, _runregex._capsize, _runtext, _runtextbeg, _runtextend - _runtextbeg, _runtextstart);
                }
            }
            else
            {
                _runmatch.Reset(_runregex, _runtext, _runtextbeg, _runtextend, _runtextstart);
            }

            // note we test runcrawl, because it is the last one to be allocated
            // If there is an alloc failure in the middle of the three allocations,
            // we may still return to reuse this instance, and we want to behave
            // as if the allocations didn't occur. (we used to test _trackcount != 0)

            if (_runcrawl != null)
            {
                _runtrackpos = _runtrack.Length;
                _runstackpos = _runstack.Length;
                _runcrawlpos = _runcrawl.Length;
                return;
            }

            InitTrackCount();

            int tracksize = _runtrackcount * 8;
            int stacksize = _runtrackcount * 8;

            if (tracksize < 32)
            {
                tracksize = 32;
            }
            if (stacksize < 16)
            {
                stacksize = 16;
            }

            _runtrack    = new int[tracksize];
            _runtrackpos = tracksize;

            _runstack    = new int[stacksize];
            _runstackpos = stacksize;

            _runcrawl    = new int[32];
            _runcrawlpos = 32;
        }
 /// <summary>
 /// Returns the result of a match based on the device Id returned from
 /// a previous match operation.
 /// </summary>
 /// <param name="profileIds">List of profile ids as integers</param>
 /// <param name="match">
 /// A <see cref="FiftyOne.Foundation.Mobile.Detection.Match"/>
 /// object created by a previous match, or via the 
 /// <see cref="CreateMatch"/> method.
 /// </param>
 /// <returns>
 /// The <see cref="FiftyOne.Foundation.Mobile.Detection.Match"/>
 /// object passed to the method updated with
 /// results for the device id.
 /// </returns>
 public Match MatchForDeviceId(IList<int> profileIds, Match match)
 {
     match.Reset();
     foreach(var profileId in profileIds)
     {
         var profile = DataSet.FindProfile(profileId);
         if (profile != null)
         {
             match.State.ExplicitProfiles.Add(profile);
         }
     }
     return match;
 }