예제 #1
0
        public IVector combine(IVector vector)
        {
            BasicSymbolVector v = (BasicSymbolVector)vector;
            int newSize         = this.rows() + v.rows();

            int[] newValue = new int[newSize];
            if (v.@base == @base)
            {
                values.AddRange(((BasicSymbolVector)vector).getdataArray());
            }
            else
            {
                SymbolBase vBase  = v.@base;
                int        length = vBase.size();
                int[]      mapper = new int[length];
                for (int i = 0; i < length; ++i)
                {
                    mapper[i] = @base.find(vBase.getSymbol(i), true);
                }
                length = v.rows();
                List <int> vValues = v.getdataArray();
                int        baseRow = this.rows();
                for (int i = 0; i < length; ++i)
                {
                    newValue[baseRow + i] = mapper[vValues[i]];
                }
            }
            return(new BasicSymbolVector(@base, newValue, false));
        }
예제 #2
0
        public virtual void write(ExtendedDataOutput @out, SymbolBase @base)
        {
            bool existing = false;
            int  id       = 0;

            if (existingBases == null)
            {
                existingBases        = new Dictionary <SymbolBase, int>();
                existingBases[@base] = 0;
            }
            else
            {
                int?curId = existingBases[@base];
                if (curId != null)
                {
                    existing = true;
                    id       = curId.Value;
                }
                else
                {
                    id = existingBases.Count;
                    existingBases[@base] = id;
                }
            }
            @out.writeInt(id);
            if (existing)
            {
                @out.writeInt(0);
            }
            else
            {
                int size = @base.size();
                @out.writeInt(size);
                for (int i = 0; i < size; ++i)
                {
                    @out.writeString(@base.getSymbol(i));
                }
            }
        }
예제 #3
0
 public override IScalar get(int index)
 {
     return(new BasicString(@base.getSymbol(values[index])));
 }