/// <summary>
        /// Initializes a new instance of the <see cref="SymbolToIndexConverter{TSymbol}" /> class copying data from the other map corresponding to the items sequence before re-indexing.
        /// It maps the symbols to the new index sequence respecting the specified result of re-indexing operation.
        /// </summary>
        /// <param name="prev">The map before re-indexing.</param>
        /// <param name="reindexingResult">The re-indexing result.</param>
        public SymbolToIndexConverter(ISymbolToIndexReadOnlyConverter <TSymbol> prev, IIndexTranslator reindexingResult)
            : this(reindexingResult.ItemsCount, prev.Comparer)
        {
            var count = reindexingResult.ItemsCount;

            for (var dstIndex = 0; dstIndex < count; dstIndex++)
            {
                AddSymbol(prev.GetSymbolAt(reindexingResult.GetSrcIndex(dstIndex)));
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="SymbolToIndexConverter{TSymbol}" /> class copying data from the other map.
        /// </summary>
        /// <param name="other">The other map.</param>
        /// <param name="maxIndex">The maximal index to copy.</param>
        public SymbolToIndexConverter(ISymbolToIndexReadOnlyConverter <TSymbol> other, int maxIndex = -1)
            : this((maxIndex > other.MaxIndex || maxIndex < 0 ? other.MaxIndex : maxIndex) + 1, other.Comparer)
        {
            var count = _indexToSymbolMap.Capacity;

            for (var dstIndex = 0; dstIndex < count; dstIndex++)
            {
                AddSymbol(other.GetSymbolAt(dstIndex));
            }
        }
        /// <summary>
        ///     Initializes a new instance of the <see cref="SymbolToIndexConverter{TSymbol}" /> class copying data from the other map
        ///     corresponding to the items sequence before re-indexing.
        ///     It maps the symbols to the new index sequence respecting the specified result of re-indexing operation.
        /// </summary>
        /// <param name="prev">The map before re-indexing.</param>
        /// <param name="reindexingResult">The re-indexing result.</param>
        public SymbolToIndexReadOnlyConverter(ISymbolToIndexReadOnlyConverter <TSymbol> prev, IIndexTranslator reindexingResult)
        {
            var count = reindexingResult.ItemsCount;

            _symbolToIndexMap = new Dictionary <TSymbol, int>(count, prev.Comparer);
            _indexToSymbolMap = new TSymbol[count];

            for (var dstIndex = 0; dstIndex < count; dstIndex++)
            {
                var srcIndex = reindexingResult.GetSrcIndex(dstIndex);
                var symbol   = prev.GetSymbolAt(srcIndex);

                _symbolToIndexMap.Add(symbol, dstIndex);
                _indexToSymbolMap[dstIndex] = symbol;
            }
        }
        /// <summary>
        ///     Initializes a new instance of the <see cref="SymbolToIndexConverter{TSymbol}" /> class copying data from the other map.
        /// </summary>
        /// <param name="other">The other map.</param>
        /// <param name="maxIndex">The maximal index to copy.</param>
        public SymbolToIndexReadOnlyConverter(ISymbolToIndexReadOnlyConverter <TSymbol> other, int maxIndex = -1)
        {
            if (maxIndex > other.MaxIndex || maxIndex < 0)
            {
                maxIndex = other.MaxIndex;
            }

            _symbolToIndexMap = new Dictionary <TSymbol, int>(maxIndex + 1, other.Comparer);
            _indexToSymbolMap = new TSymbol[maxIndex + 1];

            for (var idx = 0; idx <= maxIndex; ++idx)
            {
                var symbol = other.GetSymbolAt(idx);
                _indexToSymbolMap[idx] = symbol;
                _symbolToIndexMap.Add(symbol, idx);
            }
        }
 public void Deconstruct(out GraphConnectivityDefinition <TEdgeData> connectivity, out ISymbolToIndexReadOnlyConverter <TSymbol> symbolToIndexConverter)
 {
     connectivity           = Connectivity;
     symbolToIndexConverter = SymbolToIndexConverter;
 }
 /// <summary>Initializes a new instance of the <see cref="ReadOnlySymbolGraph{TEdgeData, TSymbol}" /> class.</summary>
 /// <param name="connectivity">The read-only connectivity.</param>
 /// <param name="symbolProvider">The read-only symbol provider.</param>
 internal ReadOnlySymbolGraph(GraphConnectivityDefinition <TEdgeData> connectivity,
                              ISymbolToIndexReadOnlyConverter <TSymbol> symbolProvider)
 {
     Connectivity           = connectivity;
     SymbolToIndexConverter = symbolProvider;
 }