?? smallarraylist.h
字號:
/***************************************************************************
SmallArrayList.h -
-------------------
begin : Tue Mar 3 2004
copyright : (C) 2004 by DigitalAirways
email : info@digitalairways.com
***************************************************************************/
/*
* Copyright (c) 2000-2004 DigitalAirways, sarl. All Rights Reserved.
*
* This software is the confidential and proprietary information of
* DigitalAirways, sarl. ("Confidential Information"). You shall not
* disclose such Confidential Information and shall use it only in
* accordance with the terms of the license agreement you entered into
* with DigitalAirways.
* A copy of this license is included in the licence.txt file included
* in this software package.
*/
/*
**************************************************************
* TODO
**************************************************************
-
**************************************************************
* HISTORY
**************************************************************
-
*/
#ifndef __SMALLARRAYLIST__
#define __SMALLARRAYLIST__
#include "EB_Utils.h"
#include "KR_Comparator.h"
class KREBDLIBS_API SmallArrayList {
private:
void** fData; // array
long fDataTabLen; // array size
long fDataCount; // next index to use, also the max + 1 of index of all existing objects
// caution: there can be NULLs pointers between the index of thelast non-NULL elt and size(). See unit test test350-23
void init();
public:
DEFINE_NEW(SmallArrayList);
DEFINE_DELETE(SmallArrayList);
void nullArray();
void createTab(long capacity, boolean setToNull=true);
SmallArrayList(long initialCapacity);
virtual ~SmallArrayList();
void ensureCapacity(long index);
long add(void* o) ;
void push(void* o) {
if(o) add(o);
}
void* set(long index, void* element);
void* get(long index) {
if(index>=fDataCount || index<0) return NULL;
return fData[index];
}
void* elementAt(long index) {
return get(index);
}
void setSize(long newSize) {
fDataCount=newSize;
}
// elements from 0 to fDataCount-1
long size() {
return fDataCount;
}
long tabLen() {
return fDataTabLen;
}
long indexOf(void* elem, int modulo=1) ;
long indexOfStr(char* elem, int modulo=1) ;
long lastIndexOfStr(char* elem) ;
void* remove(long index) ;
void sort(Comparator* c) {
insertionSort(fData, 0, fDataCount, c);
}
void clear(boolean setToNull=true) {
fDataCount=0;
if(setToNull)
nullArray();
}
//returns a shallow clone of 'this'.
// the clone is allocated with xmalloc or it is passed as parameter.
SmallArrayList* clone(SmallArrayList* matrix=NULL);
void insertionSort(void* dest[], long low, long high, Comparator* c) ;
/*
* Hashtable like management functions
*/
/*
* Set a var/val pair by creating it or updating it if it already exists.
*/
void updateVarVal(char* var, void* val);
/**
* Parse a query string and add the values that it contains in a SmallArrayList
* managing a pseudo Hashtable.
* scan : the querystring to parse
* res : the SmallArrayList to use. If it's NULL, a new one is created.
* separator : the character to use as a separator between the values. Default = '&'
* Returns : an Hashtable-like SmallArrayList containing param names and values
*
*/
static SmallArrayList* insertQueryString(char* scan, SmallArrayList* res=NULL, char separator='&');
/*
* This function considers that couples is containing
* pairs of dataName/dataValue blocs of memory, dataName
* being a string.
* It tries to find dataName containing valName and then
* returns the associated dataValue, without transferring any
* ownership.
* If the dataName is not found, it returns defValue.
*/
char* findStrHTValue(char* key, char* defValue=NULL);
/*
* Returns the "Hastabled" value associated to key as an int
*/
int findIntHTValue(char* key, int defValue=0, char** endptr = NULL);
};
// To manage SmallArrayList containing strings...
/*
* This function considers that currentLines is containing
* a set of blocs created by xmalloc() and that are owned
* by the SmallArrayList.
* It frees all these blocs and, finally, the SmallArrayList itself.
*/
KREBDLIBS_API void freeLines(SmallArrayList** currentLines, boolean deleteList=TRUE) ;
#endif
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -