Example #1
0
// return the first value in the list
const QuickString &KeyListOpsMethods::getFirst() {
	if (empty()) return _nullVal;

	//just the first item.
	begin();
	return getColVal();
}
Example #2
0
void KeyListOpsMethods::makeFreqMap() {
	_freqMap.clear();

	//make a map of values to their number of times occuring.
	for (begin(); !end(); next()) {
		_freqMap[getColVal()]++;
	}
	_freqIter = _freqMap.begin();
}
Example #3
0
// return the last value in the list
const QuickString &KeyListOpsMethods::getLast() {
	if (empty()) return _nullVal;

	//just the last item.
	begin();
	for (size_t i = 0; i < getCount() -1; i++) {
		next();
	}
	return getColVal();
}
Example #4
0
// return a delimiter-separated list of elements
const string &KeyListOpsMethods::getCollapse(const string &delimiter) {
	if (empty()) return _nullVal;

	//just put all items in one big separated list.
	_retStr.clear();
	int i=0;
	for (begin(); !end(); next()) {
		if (i > 0) _retStr += _delimStr;
		_retStr.append(getColVal());
		i++;
	}
	return _retStr;
}
Example #5
0
void KeyListOpsMethods::toArray(bool useNum, SORT_TYPE sortVal) {

	//TBD: optimize performance with better memory management.
	if (useNum) {
		_numArray.resize(_keyList->size());
		int i=0;
		for (begin(); !end(); next()) {
			_numArray[i] = getColValNum();
			i++;
		}
	} else {
		_qsArray.resize(_keyList->size());
		int i=0;
		for (begin(); !end(); next()) {
			_qsArray[i] = getColVal();
			i++;
		}
	}
	if (sortVal != UNSORTED) {
		sortArray(useNum, sortVal == ASC);
	}
}