// ColsByIdx returns a slice of columns from the row with the given
// indexes. It will return an error if any index is out of range
ColsByIdx returns a slice of columns from the row with the given
indexes. It will return an error if any index is out of range
// ColsByIdx returns a slice of columns from the row with the given // indexes . It will return an error if any index is out of range
func (r *Row) ColsByIdx(indexes ...int) ([]Column, error) {
	rval := make([]Column, 0, len(indexes))
	for _, i := range indexes {
		if i < 0 || i >= len(r.mci.info) {
			return nil, dfErrorf("There is no column %d (valid range: 0-%d)",
				i, len(r.mci.info)-1)
		}
		col := Column{ci: r.mci.info[i]}
		switch col.ci.colType {
		case ColTypeBool:
			col.boolVals = append(col.boolVals, r.rd.boolVals[r.mci.valIdx[i]])
		case ColTypeInt:
			col.intVals = append(col.intVals, r.rd.intVals[r.mci.valIdx[i]])
		case ColTypeFloat:
			col.floatVals = append(col.floatVals, r.rd.floatVals[r.mci.valIdx[i]])
		case ColTypeString:
			col.stringVals = append(col.stringVals, r.rd.stringVals[r.mci.valIdx[i]])
		default:
			panic(dfErrorf("Unexpected column type: %q", col.ci.colType))
		}
		rval = append(rval, col)
	}
	return rval, nil
}
func ( r * Row ) ColsByIdx ( indexes ... int ) ( [ ] Column , error ) { rval := make ( [ ] Column , 0 , len ( indexes ) ) for _ , i := range indexes { if i < 0 || i >= len ( r . mci . info ) { return nil , dfErrorf ( " " , i , len ( r . mci . info ) - 1 ) } col := Column { ci : r . mci . info [ i ] } switch col . ci . colType { case ColTypeBool : col . boolVals = append ( col . boolVals , r . rd . boolVals [ r . mci . valIdx [ i ] ] ) case ColTypeInt : col . intVals = append ( col . intVals , r . rd . intVals [ r . mci . valIdx [ i ] ] ) case ColTypeFloat : col . floatVals = append ( col . floatVals , r . rd . floatVals [ r . mci . valIdx [ i ] ] ) case ColTypeString : col . stringVals = append ( col . stringVals , r . rd . stringVals [ r . mci . valIdx [ i ] ] ) default : panic ( dfErrorf ( " " , col . ci . colType ) ) } rval = append ( rval , col ) } return rval , nil }
ColsByIdx returns a slice of columns from the row with the given
indexes.
ColsByIdx returns a slice of columns from the row with the given indexes .