Moved plvector.c and plvector.h from mozilla/nsprpub/lib/ds

to mozilla/xpcom.
Modified files: MANIFEST, Makefile, Makefile.in, makefile.win.
This commit is contained in:
wtc%netscape.com 1998-11-09 20:09:33 +00:00
Родитель d02ef8a9d6
Коммит da5c8ed7ae
6 изменённых файлов: 204 добавлений и 0 удалений

100
xpcom/ds/plvector.h Normal file
Просмотреть файл

@ -0,0 +1,100 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef plvector_h__
#define plvector_h__
#include "prtypes.h"
#include "prlog.h"
PR_BEGIN_EXTERN_C
/* Vectors are extensible arrays */
typedef struct PLVector {
void** data; /* the actual array of data */
PRUint32 size; /* # of elements (upperBound - 1) */
PRUint32 maxSize; /* max allocated */
PRInt32 growBy; /* grow amount */
} PLVector;
PR_EXTERN(PLVector*)
PL_NewVector(PRUint32 initialSize, PRInt32 initialGrowBy);
PR_EXTERN(void)
PL_VectorDestroy(PLVector* v);
/* Initializes an existing vector */
PR_EXTERN(void)
PL_VectorInitialize(PLVector* v, PRUint32 initialSize, PRInt32 initialGrowBy);
/* Destroys the elements, but doesn't free the vector */
PR_EXTERN(void)
PL_VectorFinalize(PLVector* v);
#define PL_VectorGetSize(v) ((v)->size)
#define PL_VECTOR_GROW_DEFAULT (-1)
PR_EXTERN(PRBool)
PL_VectorSetSize(PLVector* v, PRUint32 newSize, PRInt32 growBy);
PR_EXTERN(PRBool)
PL_VectorIsValidIndex(PLVector* v, PRUint32 index);
PR_EXTERN(void)
PL_VectorCompact(PLVector* v);
PR_EXTERN(void)
PL_VectorCopy(PLVector* dstVector, PRUint32 dstPosition,
PLVector* srcVector, PRUint32 srcPosition, PRUint32 length);
PR_EXTERN(PLVector*)
PL_VectorClone(PLVector* v);
/* Accessing elements */
#define PL_VectorGetAddr(v, index) (PR_ASSERT((index) < (v)->size), &(v)->data[index])
#define PL_VectorGet(v, index) (*PL_VectorGetAddr(v, index))
PR_EXTERN(void)
PL_VectorSet(PLVector* v, PRUint32 index, void* newElement);
/* Adds at the end */
PR_EXTERN(PRUint32)
PL_VectorAdd(PLVector* v, void* newElement);
/* Inserts new element count times at index */
PR_EXTERN(void)
PL_VectorInsert(PLVector* v, PRUint32 index, void* newElement, PRUint32 count);
/* Removes count elements at index */
PR_EXTERN(void)
PL_VectorRemove(PLVector* v, PRUint32 index, PRUint32 count);
#ifdef DEBUG
PR_EXTERN(void)
PL_VectorAssertValid(PLVector* v);
#endif
PR_END_EXTERN_C
#endif /* plvector_h__ */

Просмотреть файл

@ -18,3 +18,4 @@ nsIEnumerator.h
nsVector.h
nsMacRepository.h
nsTraceRefcnt.h
plvector.h

Просмотреть файл

@ -33,6 +33,7 @@ EXPORTS = nsCom.h \
nsIEnumerator.h \
nsTraceRefcnt.h \
nsVector.h \
plvector.h \
$(NULL)
include $(DEPTH)/config/rules.mk

Просмотреть файл

@ -38,6 +38,7 @@ EXPORTS = nsCom.h \
nsIEnumerator.h \
nsTraceRefcnt.h \
nsVector.h \
plvector.h \
$(NULL)
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))

Просмотреть файл

@ -35,6 +35,7 @@ EXPORTS = \
nsIEnumerator.h \
nsTraceRefcnt.h \
nsVector.h \
plvector.h \
$(NULL)
MODULE = xpcom

100
xpcom/public/plvector.h Normal file
Просмотреть файл

@ -0,0 +1,100 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef plvector_h__
#define plvector_h__
#include "prtypes.h"
#include "prlog.h"
PR_BEGIN_EXTERN_C
/* Vectors are extensible arrays */
typedef struct PLVector {
void** data; /* the actual array of data */
PRUint32 size; /* # of elements (upperBound - 1) */
PRUint32 maxSize; /* max allocated */
PRInt32 growBy; /* grow amount */
} PLVector;
PR_EXTERN(PLVector*)
PL_NewVector(PRUint32 initialSize, PRInt32 initialGrowBy);
PR_EXTERN(void)
PL_VectorDestroy(PLVector* v);
/* Initializes an existing vector */
PR_EXTERN(void)
PL_VectorInitialize(PLVector* v, PRUint32 initialSize, PRInt32 initialGrowBy);
/* Destroys the elements, but doesn't free the vector */
PR_EXTERN(void)
PL_VectorFinalize(PLVector* v);
#define PL_VectorGetSize(v) ((v)->size)
#define PL_VECTOR_GROW_DEFAULT (-1)
PR_EXTERN(PRBool)
PL_VectorSetSize(PLVector* v, PRUint32 newSize, PRInt32 growBy);
PR_EXTERN(PRBool)
PL_VectorIsValidIndex(PLVector* v, PRUint32 index);
PR_EXTERN(void)
PL_VectorCompact(PLVector* v);
PR_EXTERN(void)
PL_VectorCopy(PLVector* dstVector, PRUint32 dstPosition,
PLVector* srcVector, PRUint32 srcPosition, PRUint32 length);
PR_EXTERN(PLVector*)
PL_VectorClone(PLVector* v);
/* Accessing elements */
#define PL_VectorGetAddr(v, index) (PR_ASSERT((index) < (v)->size), &(v)->data[index])
#define PL_VectorGet(v, index) (*PL_VectorGetAddr(v, index))
PR_EXTERN(void)
PL_VectorSet(PLVector* v, PRUint32 index, void* newElement);
/* Adds at the end */
PR_EXTERN(PRUint32)
PL_VectorAdd(PLVector* v, void* newElement);
/* Inserts new element count times at index */
PR_EXTERN(void)
PL_VectorInsert(PLVector* v, PRUint32 index, void* newElement, PRUint32 count);
/* Removes count elements at index */
PR_EXTERN(void)
PL_VectorRemove(PLVector* v, PRUint32 index, PRUint32 count);
#ifdef DEBUG
PR_EXTERN(void)
PL_VectorAssertValid(PLVector* v);
#endif
PR_END_EXTERN_C
#endif /* plvector_h__ */