Ejemplo n.º 1
0
            private void GetSlotNames(int col, ref VBuffer <ReadOnlyMemory <char> > dst)
            {
                Contracts.Assert(col == 0);

                var nameList  = new List <ReadOnlyMemory <char> >();
                var indexList = new List <int>();

                foreach (var kvp in _collection.GetNonDefaultFeatureNames())
                {
                    nameList.Add(kvp.Value.AsMemory());
                    indexList.Add(kvp.Key);
                }

                Contracts.Assert(nameList.Count == indexList.Count);

                var editor = VBufferEditor.Create(ref dst, _collection.Count, nameList.Count);

                nameList.CopyTo(editor.Values);
                if (nameList.Count < _collection.Count)
                {
                    indexList.CopyTo(editor.Indices);
                }

                dst = editor.Commit();
            }
Ejemplo n.º 2
0
            private void GetSlotNames(int col, ref VBuffer <ReadOnlyMemory <char> > dst)
            {
                Contracts.Assert(col == 0);

                var nameList  = new List <ReadOnlyMemory <char> >();
                var indexList = new List <int>();

                foreach (var kvp in _collection.GetNonDefaultFeatureNames())
                {
                    nameList.Add(kvp.Value.AsMemory());
                    indexList.Add(kvp.Key);
                }

                var vals = dst.Values;

                if (Utils.Size(vals) < nameList.Count)
                {
                    vals = new ReadOnlyMemory <char> [nameList.Count];
                }
                Array.Copy(nameList.ToArray(), vals, nameList.Count);
                if (nameList.Count < _collection.Count)
                {
                    var indices = dst.Indices;
                    if (Utils.Size(indices) < indexList.Count)
                    {
                        indices = new int[indexList.Count];
                    }
                    Array.Copy(indexList.ToArray(), indices, indexList.Count);
                    dst = new VBuffer <ReadOnlyMemory <char> >(_collection.Count, nameList.Count, vals, indices);
                }
                else
                {
                    dst = new VBuffer <ReadOnlyMemory <char> >(_collection.Count, vals, dst.Indices);
                }
            }