Exemple #1
0
        private void Add(IList <elementType> key, resultType value, int keyPos)
        {
            int size = key.Count - keyPos;

            if (size > 0)
            {
                //add the node needed if nessesary
                if (!nodes.ContainsKey(key[0]))
                {
                    DSTNode <elementType, resultType> next = new DSTNode <elementType, resultType>();
                    next.init();
                    nodes.Add(key[0], next);
                }

                nodes[key[0]].Add(key, value, keyPos++);
            }
            else
            {
                if (result == null)
                {
                    result = new List <resultType>();
                    result.Add(value);
                    count++;
                }
                else
                {
                    throw new ArgumentException("An element with the same key already exists in the DST.");
                }
            }
        }
Exemple #2
0
 public DST()
 {
     rootNode = new DSTNode <elementType, resultType>();
     rootNode.init();
 }