Example #1
0
        private const int _preprocessThreshold = 1024; // 1024 chars -- TODO: empirically determine best threshold

        public StringTokenizer(string str, string delim, bool returnDelims)
        {
            if (str == null)
                throw new ArgumentNullException("str");

            if (string.IsNullOrEmpty(delim))
                throw new ArgumentException("No delimiter characters given!");

            var delimSet = new HashSet<char>(delim.ToCharArray());

            if (str.Length > _preprocessThreshold)
            {
                _strategy = new StringBuilderTokenParsingStrategy(str, delimSet, returnDelims);
            }
            else
            {
                _strategy = new PreProcessTokenParsingStrategy(str, delimSet, returnDelims);
            }
        }
        private const int _preprocessThreshold = 1024; // 1024 chars -- TODO: empirically determine best threshold

        public StringTokenizer(string str, string delim, bool returnDelims)
        {
            if (str == null)
            {
                throw new ArgumentNullException("str");
            }

            if (string.IsNullOrEmpty(delim))
            {
                throw new ArgumentException("No delimiter characters given!");
            }

            var delimSet = new HashSet <char>(delim.ToCharArray());

            if (str.Length > _preprocessThreshold)
            {
                _strategy = new StringBuilderTokenParsingStrategy(str, delimSet, returnDelims);
            }
            else
            {
                _strategy = new PreProcessTokenParsingStrategy(str, delimSet, returnDelims);
            }
        }