Beispiel #1
0
        /// <summary>
        /// creates the token sequence from ListA by using indA and matchLength
        /// </summary>
        /// <param name="indA"></param>
        /// <param name="indB"></param>
        /// <param name="matchLength"></param>
        /// <param name="listA"></param>
        /// <returns></returns>
        internal static Tile <T> CreateTile <T>(GSTTokenList <T> listA, int indA, int indB, int matchLength) where T : GSTToken
        {
            var list = new List <T>();

            for (int i = indA; i < indA + matchLength; i++)
            {
                list.Add(listA[i]);
            }

            return(new Tile <T>(list, indA, indB));
        }
Beispiel #2
0
            /// <summary>
            /// creates a HashingEntity and calculates the hash value for the underlying token set
            /// </summary>
            /// <param name="list"></param>
            /// <param name="startIndex"></param>
            /// <param name="mml"></param>
            /// <returns></returns>
            internal HashingEntity(GSTTokenList <T> list, int startIndex, int mml)
            {
                var l   = list.ToArray();
                var arr = new T[mml];

                for (int i = 0; i < mml; i++)
                {
                    arr[i] = l[i + startIndex];
                }

                var thing = arr.Select((t, i) => (t.GetHashCode() * (multiplicators[i % multiplicators.Length])));

                unchecked
                {
                    foreach (var element in thing)
                    {
                        hash += element;
                    }
                }


                //hash = unchecked(thing.Sum());
                Tokens = arr;
            }
Beispiel #3
0
        /// <summary>
        /// 1. generates the hash values for all sub sequences of list with a length of mml
        /// 2. stores the created HashingEntity objects in the returned dictionary
        /// </summary>
        /// <param name="list"></param>
        /// <param name="mml"></param>
        /// <returns></returns>
        internal static Dictionary <int, IList <HashingEntity> > CreateHashMap(GSTTokenList <T> list, Int32 mml)
        {
            var dict = new Dictionary <int, IList <HashingEntity> >();

            // it needs to run exactly until COUNT - MML
            for (int i = 0; i <= list.Count - mml; i++)
            {
                var entity = new HashingEntity(list, i, mml);
                var hash   = entity.GetHashCode();

                if (dict.ContainsKey(hash))
                {
                    dict[hash].Add(entity);
                }
                else
                {
                    dict[hash] = new List <HashingEntity> {
                        entity
                    };
                }
            }

            return(dict);
        }
 public void CreateAlgorithm(GSTTokenList<GSTToken<char>> a, GSTTokenList<GSTToken<char>> b)
 {
     CreateAlgorithm(new[] {a, b});
 }
Beispiel #5
0
 public HashingGSTAlgorithm(GSTTokenList <T> a, GSTTokenList <T> b) : base(a, b)
 {
 }
Beispiel #6
0
 public void SetUp()
 {
     ListA = GSTHelper.FromString("Hallo");
     ListB = GSTHelper.FromString("Hallo");
 }
 public void CreateAlgorithm(GSTTokenList <GSTToken <char> > a, GSTTokenList <GSTToken <char> > b)
 {
     CreateAlgorithm(new[] { a, b });
 }
Beispiel #8
0
        /// <summary>
        /// turns the 
        /// </summary>
        /// <param name="source"></param>
        /// <returns></returns>
        public static GSTTokenList<GSTToken<char>> FromString(string source)
        {
            var list = new GSTTokenList<GSTToken<char>>(source.ToCharArray().Select(c => new GSTToken<char>(c)));

            return list;
        }
Beispiel #9
0
 public void SetUp()
 {
     ListA = GSTHelper.FromString("Hallo");
     ListB = GSTHelper.FromString("Hallo");
 }