class SparseVector extends Vector {

	@Override
	public SparseVector slice(int[] indices) {
		SparseVector sliced = new SparseVector(indices.length);
		int nnz = 0;
		sliced.indices = new int[indices.length];
		sliced.values = new double[indices.length];

		for (int i = 0; i < indices.length; i++) {
			int pos = Arrays.binarySearch(this.indices, indices[i]);
			if (pos >= 0) {
				sliced.indices[nnz] = i;
				sliced.values[nnz] = this.values[pos];
				nnz++;
			}
		}

		if (nnz < sliced.indices.length) {
			sliced.indices = Arrays.copyOf(sliced.indices, nnz);
			sliced.values = Arrays.copyOf(sliced.values, nnz);
		}

		return sliced;
	}

	public  SparseVector();
	public  SparseVector(int n);
	public  SparseVector(int n, int[] indices, double[] values);
	public  SparseVector(int n, Map<Integer, Double> kv);

}