Пример #1
0
 /// <summary>This constructor is for cloning purposes.</summary>
 /// <param name="set">The set to clone.</param>
 /// <runtime>O(n)</runtime>
 internal SetHashLinked(SetHashLinked <T> set)
 {
     _equate = set._equate;
     _hash   = set._hash;
     _table  = (Node[])set._table.Clone();
     _count  = set._count;
 }
Пример #2
0
 private SetHashLinked(SetHashLinked <T> setHashList)
 {
     this._equate = setHashList._equate;
     this._hash   = setHashList._hash;
     this._table  = setHashList._table.Clone() as Node[];
     this._count  = setHashList._count;
 }
Пример #3
0
 /// <summary>Constructs a new GraphSetOmnitree.</summary>
 /// <param name="equate">The equate delegate for the data structure to use.</param>
 /// <param name="compare">The compare delegate for the data structure to use.</param>
 /// <param name="hash">The hash delegate for the datastructure to use.</param>
 public GraphSetOmnitree(Equate <T> equate, Compare <T> compare, Hash <T> hash)
 {
     _nodes = new SetHashLinked <T>(equate, hash);
     _edges = new OmnitreePointsLinked <Edge, T, T>(
         (Edge a, out T start, out T end) =>
     {
         start = a.Start;
         end   = a.End;
     },
         compare, compare);
 }
Пример #4
0
        /// <summary>Adds an edge to the graph.</summary>
        /// <param name="start">The starting point of the edge.</param>
        /// <param name="end">The ending point of the edge.</param>
        public void Add(T start, T end)
        {
            if (!_map.Contains(start))
            {
                throw new InvalidOperationException("Adding an edge to a non-existing starting node.");
            }
            if (!_map[start].Contains(end))
            {
                throw new InvalidOperationException("Adding an edge to a non-existing ending node.");
            }
            if (_map[start] is null)
            {
                _map[start] = new SetHashLinked <T>(_map.Equate, _map.Hash);
            }

            _map[start].Add(end);
        }
Пример #5
0
        /// <summary>Constructs a new GraphSetOmnitree.</summary>
        /// <param name="equate">The equate delegate for the data structure to use.</param>
        /// <param name="compare">The compare delegate for the data structure to use.</param>
        /// <param name="hash">The hash delegate for the datastructure to use.</param>
        public GraphSetOmnitree(
            Equate <T> equate   = null,
            Compare <T> compare = null,
            Hash <T> hash       = null)
        {
            equate  = equate ?? Equate.Default;
            compare = compare ?? Compare.Default;
            hash    = hash ?? Hash.Default;

            _nodes = new SetHashLinked <T>(equate, hash);
            _edges = new OmnitreePointsLinked <Edge, T, T>(
                (Edge a, out T start, out T end) =>
            {
                start = a.Start;
                end   = a.End;
            },
                compare, compare);
        }
Пример #6
0
        /// <summary>Constructs a new GraphSetOmnitree.</summary>
        /// <param name="equate">The equate delegate for the data structure to use.</param>
        /// <param name="compare">The compare delegate for the data structure to use.</param>
        /// <param name="hash">The hash delegate for the datastructure to use.</param>
        public GraphSetOmnitree(
            Func <T, T, bool>?equate           = null,
            Func <T, T, CompareResult>?compare = null,
            Func <T, int>?hash = null)
        {
            equate ??= Equate;
            compare ??= Compare;
            hash ??= DefaultHash;

            _nodes = new SetHashLinked <T>(equate, hash);
            _edges = new OmnitreePointsLinked <Edge, T, T>(
                (Edge a, out T start, out T end) =>
            {
                start = a.Start;
                end   = a.End;
            },
                compare, compare);
        }
Пример #7
0
 /// <summary>This constructor is for cloning purposes.</summary>
 /// <param name="graph">The graph to construct a clone of.</param>
 internal GraphSetOmnitree(GraphSetOmnitree <T> graph)
 {
     _edges = graph._edges.Clone() as OmnitreePointsLinked <Edge, T, T>;
     _nodes = graph._nodes.Clone() as SetHashLinked <T>;
 }
Пример #8
0
 /// <summary>This constructor is for cloning purposes.</summary>
 /// <param name="graph">The graph to construct a clone of.</param>
 internal GraphSetOmnitree(GraphSetOmnitree <T> graph)
 {
     _edges = graph._edges.Clone();
     _nodes = graph._nodes.Clone();
 }
Пример #9
0
 public Node(T?parent, SetHashLinked <T, TEquate, THash> children)
 {
     Parent   = parent;
     Children = children;
 }
Пример #10
0
 public Node(T parent, SetHashLinked <T> children)
 {
     Parent   = parent;
     Children = children;
 }
Пример #11
0
 private GraphSetOmnitree(GraphSetOmnitree <T> graph)
 {
     this._edges = graph._edges.Clone() as OmnitreePointsLinked <Edge, T, T>;
     this._nodes = graph._nodes.Clone() as SetHashLinked <T>;
 }