当前位置: 首页>>代码示例>>C++>>正文


C++ DynamicArray::length方法代码示例

本文整理汇总了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));
}
开发者ID:enjoythelive1,项目名称:memory-manage,代码行数:7,代码来源:DynamicArray.cpp

示例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);
         }
     }
 }
开发者ID:rajkosto,项目名称:deps-rcf,代码行数:29,代码来源:SerializeDynamicArray.hpp

示例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));
}
开发者ID:enjoythelive1,项目名称:memory-manage,代码行数:9,代码来源:DynamicArray.cpp

示例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;
            }
        }

    }

}
开发者ID:enjoythelive1,项目名称:memory-manage,代码行数:27,代码来源:DynamicArray.cpp

示例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;
}
开发者ID:enjoythelive1,项目名称:memory-manage,代码行数:13,代码来源:DynamicArray.cpp

示例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);
}
开发者ID:enjoythelive1,项目名称:memory-manage,代码行数:44,代码来源:DynamicArray.cpp

示例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;
}
开发者ID:jgardella,项目名称:CS585,代码行数:19,代码来源:buildingfactory.cpp

示例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;
        }
    }
}
开发者ID:benavrhm,项目名称:pl-nk,代码行数:21,代码来源:plonk_InputDictionary.cpp

示例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);
}
开发者ID:enjoythelive1,项目名称:memory-manage,代码行数:6,代码来源:DynamicArray.cpp


注:本文中的DynamicArray::length方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。