亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? arraylist.cpp

?? funambol windows mobile plugin source code, the source code is taken from the funambol site
?? CPP
字號:
/*
 * Copyright (C) 2003-2007 Funambol, Inc.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY, TITLE, NONINFRINGEMENT or FITNESS FOR A PARTICULAR
 * PURPOSE.  See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
 * 02111-1307  USA
 */


#include "base/util/ArrayList.h"

/**
 * This class implements a simple linked list that can be accessed by index too.
 * This class does not make use of C++ templates by choice, since it must be
 * as much easier and portable as possible.
 *
 * Since this class works with pointers, it can be instructed to delete the
 * list elements at object destruction. If the property autoDeleteElements is
 * TRUE all elements are delete using the C++ delete operator (therefore, make
 * sure elements are allocated with a compatible memory allocation function -
 * such as the C++ new operator)
 */

ArrayList::ArrayList() : head(0), iterator(0), lastElement(0) {
    count = 0;
}

ArrayList::ArrayList(const ArrayList &other) {
    count = 0;
    head = iterator = lastElement = 0;
    for (Element *p = other.head; p; p = p->n) {
        add( *(p->e) );
    }
}

ArrayList::~ArrayList() {
    clear();
}

/**
 * Is this list empty?
 */
bool ArrayList::isEmpty() {
    return (head == NULL);
}

/**
 * Adds a new element at the specified index. If index is greater than
 * the list size the element is appended.
 * The element is dinamically duplicated so that the caller can release
 * the element at any time. This method returns the position (0 based) at which
 * the element has been inserted. It can be different by index if index is out
 * of the array bounds, in that case element is appended as last element.
 * It returns -1 in case of errors.
 *
 * @param index the insertion position
 * @param element the element to insert - NULL is not allowed!
 */
int ArrayList::add(int index, ArrayElement& element) {
    if (index < 0) {
        return -1;
    }

    int s = size();
    if (index > s) {
        index = s;
    }

    Element* newElement = new Element();

    newElement->e = element.clone();
    newElement->n = NULL;

    Element* e;
    if (index == s) {
        // Inserting the new element at the end
        e = lastElement;

    }
    else {
    // Inserting the new element at the index-th position
        e = head;
    for (int i=0; i<index-1; ++i) {
        e = e->n;
    }
    }

    if (e == NULL || index == 0) {
        //
        // Insertion at the beginning of the array
        //
        newElement->n = head;
        head = newElement;

        if (e == NULL) {
            lastElement = newElement;
        }
        count++;
        return index;
    }

    if (e->n) {
        //
        // Insertion in the middle of the array
        //
        newElement->n = e->n;
        e->n = newElement;
    } else {
        //
        // Insertion at the end of the array
        //
        e->n = newElement;
        lastElement = newElement;
    }

    count++;

    return index;
}

/**
 * Same as add(index, element), but appending at the end of the array.
 *
 * @param element the element to insert
 */
int ArrayList::add(ArrayElement& element) {
    return add(size(), element);
}

/**
* Add all the ArrayElement of the given ArrayList to the current
* array list
*/
int ArrayList::add(ArrayList* list) {
    int ret = 0;
    for (int i = 0; i < list->size(); i++) {
        ret = ret + add(*(ArrayElement*)list->get(i));
    }
    return ret;
}


int ArrayList::removeElementAt(int index) {

    int s = size() - 1;

    if (index > s) {
        index = s;
    }

    if (index < 0) {
        return -1;
    }

    //
    // deleting the existing element at the index-th position
    //
    Element* e = head;
    Element* after = NULL;
    Element* before = head;

    for (int i=0; i<index; ++i) {
        before = e;
        e = e->n;
    }

    if (e == NULL) {
        return 0;
    }

    if (e->n) {
        after = e->n;
    }
    else {
        // (e->n = NULL) means that 'e' is the last one
        lastElement = before;
    }

    delete e;
    e = NULL;

    before->n = after;

    if (index == 0) {
        head = after;
    }

    count--;
    return index;
}

/**
 * Frees the list. All elements are freed as well.
 */
void ArrayList::clear()
{
    Element* p = head;
    while (p) {
        delete p->e;
        head = p->n;
        delete p;
        p = head;
    }
    count = 0;
    head = NULL;
    lastElement = NULL;
}

/**
 * Returns the index-th element of the array or NULL if index is out of
 * the array bounds.
 *
 * @param index the element position
 */
ArrayElement* ArrayList::get(int index) {

    if ( index<0 ) {
        return NULL;
    }

    Element* e = head;
    for(int i=0; e && i<index; ++i) {
        e = e->n;
    }
    if(!e)
        return NULL;
    else
        return e->e;
}

/**
 * Returns the array size.
 */
int ArrayList::size() {
/*    Element *e = head;
    int i = 0;
    while (e) {
        ++i;
        e = e->n;
    }

    return i;*/
    return count;
}

ArrayElement* ArrayList::front() {
    iterator = head;
    return (iterator) ? iterator->e : 0 ;
}
ArrayElement* ArrayList::next() {
    if(!iterator) {
        return 0;
    }
    iterator = iterator->n;
    return (iterator) ? iterator->e : 0 ;
}

ArrayElement* ArrayList::prev() {
    Element *e;

    if( !iterator)
        return 0;
    if(iterator == head)
        return 0;
    for(e = head; e->n == iterator; e = e->n) {
        if(!e)
            return 0;
    }
    return e->e;
}

ArrayElement* ArrayList::back() {
    for(iterator = head; iterator->n; iterator = iterator->n);
    return iterator->e;
}

/**
 * Same as get(index)
 */
ArrayElement* ArrayList::operator[] (int index) {
    return get(index);
}

ArrayList& ArrayList::operator= (const ArrayList &v) {
    clear();
    for (Element *p = v.head; p; p = p->n) {
        add( *(p->e) );
    }
    return *this;
}

ArrayList* ArrayList::clone() {

    ArrayList* ret = new ArrayList();
    int dim = size();
    for (int i = 0; i < dim; i++) {

        ret->add(*((ArrayElement*)get(i)));
    }
    return ret;

}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
丝瓜av网站精品一区二区| 国产成人精品午夜视频免费| 成人18精品视频| 久久久久97国产精华液好用吗| 日韩精品一二区| 欧美日韩二区三区| 夜夜揉揉日日人人青青一国产精品| 99热这里都是精品| 国产午夜精品久久久久久免费视 | 国产成人亚洲综合a∨婷婷 | 欧美国产欧美亚州国产日韩mv天天看完整| 污片在线观看一区二区| 欧美日韩一区视频| 亚洲高清免费在线| 欧美精品少妇一区二区三区| 亚洲午夜久久久久中文字幕久| 在线视频一区二区三区| 亚洲电影你懂得| 日韩精品一区二区三区中文不卡| 懂色av一区二区三区免费观看| 一区二区三区高清在线| 日韩欧美国产综合一区| 97精品国产露脸对白| 亚洲va国产va欧美va观看| 国产亚洲精久久久久久| 欧美三级韩国三级日本三斤| 国产一区二区影院| 亚洲一区二区三区四区五区中文| 欧美va亚洲va| 欧美三电影在线| 国产99久久久国产精品免费看 | 久久综合久久99| 91色视频在线| 国产精品一区免费视频| 亚洲一区二区三区精品在线| 久久色在线视频| 欧美日韩亚洲不卡| www.久久精品| 国产综合久久久久久久久久久久| 一区二区三区鲁丝不卡| 久久嫩草精品久久久精品一| 欧美三片在线视频观看| 成人精品国产福利| 久久99精品国产.久久久久| 亚洲精品国产一区二区三区四区在线| 精品国偷自产国产一区| 欧美少妇xxx| 波多野结衣中文字幕一区 | 国产精品亚洲综合一区在线观看| 亚洲综合男人的天堂| 国产视频一区二区在线| 欧美精品vⅰdeose4hd| 91麻豆国产福利在线观看| 国产成人午夜电影网| 久久99久久99精品免视看婷婷 | 久久九九99视频| 正在播放一区二区| 欧美视频第二页| 99久久久免费精品国产一区二区| 国产经典欧美精品| 国内精品久久久久影院色| 日本欧美一区二区三区| 午夜免费欧美电影| 天天免费综合色| 亚洲va中文字幕| 无吗不卡中文字幕| 五月天亚洲精品| 午夜精品久久久| 亚州成人在线电影| 亚洲国产成人91porn| 亚洲18女电影在线观看| 亚洲伊人色欲综合网| 亚洲最大色网站| 午夜成人免费电影| 亚洲成在线观看| 婷婷久久综合九色综合伊人色| 亚洲自拍与偷拍| 亚洲高清一区二区三区| 午夜精品久久久久久不卡8050| 亚洲第一久久影院| 日韩精品亚洲专区| 日韩av不卡一区二区| 日本少妇一区二区| 国产制服丝袜一区| 粉嫩av一区二区三区粉嫩| 99re这里只有精品视频首页| 欧美在线综合视频| 欧美一级片在线观看| 欧美精品一区二区三区很污很色的| xnxx国产精品| 国产精品久久久久天堂| 一区二区三区中文字幕精品精品| 午夜电影一区二区三区| 九一久久久久久| proumb性欧美在线观看| 91黄色免费网站| 欧美一级理论片| 国产午夜精品一区二区| 亚洲欧美激情视频在线观看一区二区三区 | 色婷婷综合视频在线观看| 在线观看国产一区二区| 欧美日韩亚洲高清一区二区| 日韩欧美国产电影| 久久久精品国产免大香伊| 日韩毛片视频在线看| 亚洲国产人成综合网站| 久久国内精品自在自线400部| 从欧美一区二区三区| 欧美日韩日日摸| 久久精品人人做人人爽人人| 国产一区不卡视频| 欧洲精品在线观看| 精品1区2区在线观看| 亚洲欧美激情插| 九色综合狠狠综合久久| 91丨porny丨户外露出| 欧美一区二区三区思思人| 中文字幕不卡一区| 香蕉成人啪国产精品视频综合网| 国产精品一二三四区| 欧美日本一区二区在线观看| 日本一区二区在线不卡| 日精品一区二区三区| 99久久久久久| 欧美精品一区二区三| 亚洲一区二区在线视频| 国产成人免费视频一区| 欧美疯狂性受xxxxx喷水图片| 国产精品系列在线| 美女脱光内衣内裤视频久久网站 | 一区二区三区四区不卡在线 | 亚洲激情六月丁香| 国产一区二区导航在线播放| 欧美日韩精品三区| 亚洲人精品午夜| 国产精品亚洲第一区在线暖暖韩国| 在线观看欧美日本| 亚洲欧洲精品天堂一级| 国产精品亚洲一区二区三区在线 | 久久精品在这里| 日本视频在线一区| 欧美三级在线看| 亚洲天堂中文字幕| 成人激情免费视频| 国产天堂亚洲国产碰碰| 久久电影国产免费久久电影 | 日韩午夜激情电影| 亚洲v精品v日韩v欧美v专区| 91麻豆高清视频| 中文字幕中文字幕在线一区| 国产精品1024| 国产亚洲女人久久久久毛片| 精品一区二区三区久久| 欧美一区二区三区免费视频| 亚洲国产cao| 欧美日韩不卡在线| 亚洲成a人v欧美综合天堂| 91成人在线观看喷潮| 亚洲三级理论片| 99在线精品一区二区三区| 国产精品情趣视频| 国产成人99久久亚洲综合精品| 欧美sm美女调教| 国产在线一区二区| 国产网站一区二区三区| 国产成人自拍网| 国产欧美日韩亚州综合| 国产成人精品网址| 国产精品美女久久久久久久网站| 成人avav影音| 亚洲欧美日韩综合aⅴ视频| 色综合久久久久综合| 亚洲精品国产一区二区精华液| 91久久精品一区二区| 夜夜操天天操亚洲| 欧美一区午夜视频在线观看| 免费的国产精品| 久久久99免费| 99视频一区二区| 亚洲韩国精品一区| 欧美一区二区成人6969| 激情都市一区二区| 国产日韩欧美综合一区| av电影在线观看完整版一区二区| 国产九九视频一区二区三区| 国产欧美一二三区| 91视频一区二区| 日韩高清不卡一区| 久久综合久久99| av电影在线观看一区| 午夜视频在线观看一区| 精品福利在线导航| 成人av网站在线观看免费| 亚洲午夜日本在线观看| 精品国精品国产尤物美女| 成人av集中营| 日韩精品免费视频人成| 精品国偷自产国产一区| 色噜噜狠狠成人网p站| 秋霞影院一区二区|