本文整理汇总了C++中DynamicArray::length方法的典型用法代码示例。如果您正苦于以下问题:C++ DynamicArray::length方法的具体用法?C++ DynamicArray::length怎么用?C++ DynamicArray::length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DynamicArray
的用法示例。
在下文中一共展示了DynamicArray::length方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setToSize
DynamicArray<T,chrunkSize>::DynamicArray(DynamicArray<T,chrunkSize> &other):items(0)
{
setToSize(other.length());
for(size_t i = 0; i < other.length(); i++)
set(i, other.get(i));
}
示例2: serializeDynamicArray
inline void serializeDynamicArray(
RCF::TrueType *,
Archive &ar,
DynamicArray<T,N> &da)
{
if (ar.isRead())
{
I_Encoding &e = ar.getIstream()->getEncoding();
DataPtr data;
bool bRet = ar.getIstream()->get( data );
if (bRet)
{
UInt32 nCount = e.getCount( data , (T *) NULL);
da.get() = new T[ nCount ];
da.length() = nCount;
e.toObject(data, da.get(), nCount );
}
}
else if (ar.isWrite())
{
if (da.length() > 0)
{
I_Encoding &e = ar.getOstream()->getEncoding();
DataPtr data;
e.toData(data, da.get(), da.length() );
ar.getOstream()->put(data);
}
}
}
示例3: clear
DynamicArray<T,chrunkSize> DLL_EXPORT DynamicArray<T,chrunkSize>::operator =(DynamicArray<T,chrunkSize> &other)
{
clear();
setToSize(other.length());
for(size_t i = 0; i < other.length(); i++)
set(i, other.get(i));
}
示例4: insertionSort
void insertionSort(DynamicArray<T, chrunkSize> &list, size_t start=0, size_t end=0, signed char (*comp)(T &item1, T &item2) = 0){
if(!comp)
comp = defaultComparer<T>;
if(!end)
end = list.length() - 1;
if(start - end <= 1){
return;
}
T vholder;
for(size_t sorted = start + 1; sorted <= end; sorted++){
for(size_t i = sorted; i > start; i--) {
if(comp(list[i], list[i - 1]) == -1) {
vholder = list[i - 1];
list[i - 1] = list[i];
list[i] = vholder;
} else {
break;
}
}
}
}
示例5: char
bool DLL_EXPORT DynamicArray<T,chrunkSize>::equal(DynamicArray<T,chrunkSize> &other, signed char (*comp)(T &item1, T &item2) = 0){
if (length() != other.length()) return false;
if(!comp)
comp = defaultComparer<T>;
for(size_t i = 0; i < length(); i++){
if (!comp(this[i], other[i]))
return false;
}
return true;
}
示例6: quicksort
void quicksort(DynamicArray<T, chrunkSize> &list, size_t start=0, size_t end=0, signed char (*comp)(T &item1, T &item2) = 0){
if(!comp)
comp = defaultComparer<T>;
if(!end)
end = list.length() - 1;
if (end - start < 8)
return insertionSort(list, start, end, comp);
size_t pivot = end;
size_t leftEnding = start, rightEnding = end - 1;
T valueHolder;
signed char lr, lp, rp;
while (leftEnding != rightEnding) {
lr = comp(list[leftEnding], list[rightEnding]);
lp = comp(list[leftEnding], list[pivot]);
rp = comp(list[rightEnding], list[pivot]);
if (lr == 1 && lp == 1) {
valueHolder = list[leftEnding];
list[leftEnding] = list[rightEnding];
list[rightEnding] = valueHolder;
leftEnding++;
rightEnding--;
} else {
if (lp == -1)
leftEnding++;
if(rp == 1)
rightEnding--;
}
}
valueHolder = list[leftEnding];
list[leftEnding] = list[pivot];
list[pivot] = valueHolder;
quicksort(list, start, leftEnding - 1, comp);
quicksort(list, leftEnding + 1, end, comp);
}
示例7: get
Building* BuildingFactory::get(std::string type, unsigned int corner1X, unsigned int corner1Y, unsigned int teamNum)
{
unsigned int i;
tBuildingInfo* info = *buildingInfos->get(type);
BuildingFunction* function = NULL;
if(type.compare("grandhall") == 0)
function = new GrandHallFunction(corner1X + 2, corner1Y - 1, info->behavioralConfig);
else if(type.compare("blacksmith") == 0)
function = new BlacksmithFunction(info->behavioralConfig);
else if(type.compare("apothecary") == 0)
function = new ApothecaryFunction(info->behavioralConfig);
Building* building = new Building(type, corner1X, corner1Y, teamNum, info->behavioralConfig, function);
DynamicArray<SceneNode*>* nodes = building->getSceneNodes();
for(i = 0; i < nodes->length(); i++)
{
SceneManager::getInstance()->addSceneNode(*nodes->get(i));
}
return building;
}
示例8: resetExpiredUnits
void InputDictionary::resetExpiredUnits() throw()
{
DynamicArray items = this->getValues();
const int numItems = items.length();
for (int i = 0; i < numItems; ++i)
{
Dynamic& item = items.atUnchecked (i);
const int type = item.getTypeCode();
switch (type)
{
case TypeCode::FloatUnit: item.asUnchecked<FloatUnit>().resetIfExpired(); break;
case TypeCode::DoubleUnit: item.asUnchecked<DoubleUnit>().resetIfExpired(); break;
case TypeCode::IntUnit: item.asUnchecked<IntUnit>().resetIfExpired(); break;
case TypeCode::ShortUnit: item.asUnchecked<ShortUnit>().resetIfExpired(); break;
case TypeCode::Int24Unit: item.asUnchecked<Int24Unit>().resetIfExpired(); break;
case TypeCode::LongUnit: item.asUnchecked<LongUnit>().resetIfExpired(); break;
}
}
}
示例9: sort
void DLL_EXPORT sort(DynamicArray<T, chrunkSize> &list, signed char (*comp)(T &item1, T &item2) = 0){
if(!comp)
comp = defaultComparer<T>;
quicksort(list, 0, list.length() - 1, comp);
}