зеркало из https://github.com/mozilla/pjs.git
improved deque API a tad
This commit is contained in:
Родитель
86ea166dba
Коммит
3d3143056b
|
@ -139,6 +139,22 @@ void* nsDeque::Pop() {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method gets called you want to peek at the topmost
|
||||||
|
* member without removing it.
|
||||||
|
*
|
||||||
|
* @update gess4/18/98
|
||||||
|
* @param nada
|
||||||
|
* @return last item in container
|
||||||
|
*/
|
||||||
|
void* nsDeque::Peek() {
|
||||||
|
void* result=0;
|
||||||
|
if(mSize>0) {
|
||||||
|
result=mData[mOrigin];
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove and return the last item in the container.
|
* Remove and return the last item in the container.
|
||||||
*
|
*
|
||||||
|
@ -219,7 +235,25 @@ nsDequeIterator nsDeque::End(void) const{
|
||||||
* @param aFunctor object to call for each member
|
* @param aFunctor object to call for each member
|
||||||
* @return *this
|
* @return *this
|
||||||
*/
|
*/
|
||||||
const void* nsDeque::ForEach(nsDequeFunctor& aFunctor) const{
|
const void nsDeque::ForEach(nsDequeFunctor& aFunctor) const{
|
||||||
|
int i=0;
|
||||||
|
for(i=0;i<mSize;i++){
|
||||||
|
void* obj=ObjectAt(i);
|
||||||
|
obj=aFunctor(obj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call this method when you wanto to iterate all the
|
||||||
|
* members of the container, passing a functor along
|
||||||
|
* to call your code. Iteration continues until your
|
||||||
|
* functor returns a non-null.
|
||||||
|
*
|
||||||
|
* @update gess4/20/98
|
||||||
|
* @param aFunctor object to call for each member
|
||||||
|
* @return *this
|
||||||
|
*/
|
||||||
|
const void* nsDeque::FirstThat(nsDequeFunctor& aFunctor) const{
|
||||||
int i=0;
|
int i=0;
|
||||||
for(i=0;i<mSize;i++){
|
for(i=0;i<mSize;i++){
|
||||||
void* obj=ObjectAt(i);
|
void* obj=ObjectAt(i);
|
||||||
|
@ -230,6 +264,7 @@ const void* nsDeque::ForEach(nsDequeFunctor& aFunctor) const{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/******************************************************
|
/******************************************************
|
||||||
* Here comes the nsDequeIterator class...
|
* Here comes the nsDequeIterator class...
|
||||||
******************************************************/
|
******************************************************/
|
||||||
|
@ -378,10 +413,22 @@ void* nsDequeIterator::GetCurrent(void) {
|
||||||
* @param aFunctor object to call for each member
|
* @param aFunctor object to call for each member
|
||||||
* @return *this
|
* @return *this
|
||||||
*/
|
*/
|
||||||
const void* nsDequeIterator::ForEach(nsDequeFunctor& aFunctor) const{
|
const void nsDequeIterator::ForEach(nsDequeFunctor& aFunctor) const{
|
||||||
return mDeque.ForEach(aFunctor);
|
mDeque.ForEach(aFunctor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call this method when you wanto to iterate all the
|
||||||
|
* members of the container, passing a functor along
|
||||||
|
* to call your code.
|
||||||
|
*
|
||||||
|
* @update gess4/20/98
|
||||||
|
* @param aFunctor object to call for each member
|
||||||
|
* @return *this
|
||||||
|
*/
|
||||||
|
const void* nsDequeIterator::FirstThat(nsDequeFunctor& aFunctor) const{
|
||||||
|
return mDeque.FirstThat(aFunctor);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* conduct automated self test for this class
|
* conduct automated self test for this class
|
||||||
|
|
|
@ -102,6 +102,15 @@ friend class nsDequeIterator;
|
||||||
* @return ptr to first item in container
|
* @return ptr to first item in container
|
||||||
*/
|
*/
|
||||||
void* Pop(void);
|
void* Pop(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return topmost item without removing it.
|
||||||
|
*
|
||||||
|
* @update gess4/18/98
|
||||||
|
* @param none
|
||||||
|
* @return ptr to first item in container
|
||||||
|
*/
|
||||||
|
void* Peek(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove and return the last item in the container.
|
* Remove and return the last item in the container.
|
||||||
|
@ -157,7 +166,19 @@ friend class nsDequeIterator;
|
||||||
* @param aFunctor object to call for each member
|
* @param aFunctor object to call for each member
|
||||||
* @return *this
|
* @return *this
|
||||||
*/
|
*/
|
||||||
const void* ForEach(nsDequeFunctor& aFunctor) const;
|
const void ForEach(nsDequeFunctor& aFunctor) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call this method when you wanto to iterate all the
|
||||||
|
* members of the container, passing a functor along
|
||||||
|
* to call your code. This process will interupt if
|
||||||
|
* your function returns a null to this iterator.
|
||||||
|
*
|
||||||
|
* @update gess4/20/98
|
||||||
|
* @param aFunctor object to call for each member
|
||||||
|
* @return *this
|
||||||
|
*/
|
||||||
|
const void* FirstThat(nsDequeFunctor& aFunctor) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Perform automated selftest on the deque
|
* Perform automated selftest on the deque
|
||||||
|
@ -346,8 +367,19 @@ public:
|
||||||
* @param aFunctor object to call for each member
|
* @param aFunctor object to call for each member
|
||||||
* @return *this
|
* @return *this
|
||||||
*/
|
*/
|
||||||
const void* ForEach(nsDequeFunctor& aFunctor) const;
|
const void ForEach(nsDequeFunctor& aFunctor) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call this method when you wanto to iterate all the
|
||||||
|
* members of the container, passing a functor along
|
||||||
|
* to call your code.
|
||||||
|
*
|
||||||
|
* @update gess4/20/98
|
||||||
|
* @param aFunctor object to call for each member
|
||||||
|
* @return *this
|
||||||
|
*/
|
||||||
|
const void* FirstThat(nsDequeFunctor& aFunctor) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
PRInt32 mIndex;
|
PRInt32 mIndex;
|
||||||
const nsDeque& mDeque;
|
const nsDeque& mDeque;
|
||||||
|
|
|
@ -139,6 +139,22 @@ void* nsDeque::Pop() {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method gets called you want to peek at the topmost
|
||||||
|
* member without removing it.
|
||||||
|
*
|
||||||
|
* @update gess4/18/98
|
||||||
|
* @param nada
|
||||||
|
* @return last item in container
|
||||||
|
*/
|
||||||
|
void* nsDeque::Peek() {
|
||||||
|
void* result=0;
|
||||||
|
if(mSize>0) {
|
||||||
|
result=mData[mOrigin];
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove and return the last item in the container.
|
* Remove and return the last item in the container.
|
||||||
*
|
*
|
||||||
|
@ -219,7 +235,25 @@ nsDequeIterator nsDeque::End(void) const{
|
||||||
* @param aFunctor object to call for each member
|
* @param aFunctor object to call for each member
|
||||||
* @return *this
|
* @return *this
|
||||||
*/
|
*/
|
||||||
const void* nsDeque::ForEach(nsDequeFunctor& aFunctor) const{
|
const void nsDeque::ForEach(nsDequeFunctor& aFunctor) const{
|
||||||
|
int i=0;
|
||||||
|
for(i=0;i<mSize;i++){
|
||||||
|
void* obj=ObjectAt(i);
|
||||||
|
obj=aFunctor(obj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call this method when you wanto to iterate all the
|
||||||
|
* members of the container, passing a functor along
|
||||||
|
* to call your code. Iteration continues until your
|
||||||
|
* functor returns a non-null.
|
||||||
|
*
|
||||||
|
* @update gess4/20/98
|
||||||
|
* @param aFunctor object to call for each member
|
||||||
|
* @return *this
|
||||||
|
*/
|
||||||
|
const void* nsDeque::FirstThat(nsDequeFunctor& aFunctor) const{
|
||||||
int i=0;
|
int i=0;
|
||||||
for(i=0;i<mSize;i++){
|
for(i=0;i<mSize;i++){
|
||||||
void* obj=ObjectAt(i);
|
void* obj=ObjectAt(i);
|
||||||
|
@ -230,6 +264,7 @@ const void* nsDeque::ForEach(nsDequeFunctor& aFunctor) const{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/******************************************************
|
/******************************************************
|
||||||
* Here comes the nsDequeIterator class...
|
* Here comes the nsDequeIterator class...
|
||||||
******************************************************/
|
******************************************************/
|
||||||
|
@ -378,10 +413,22 @@ void* nsDequeIterator::GetCurrent(void) {
|
||||||
* @param aFunctor object to call for each member
|
* @param aFunctor object to call for each member
|
||||||
* @return *this
|
* @return *this
|
||||||
*/
|
*/
|
||||||
const void* nsDequeIterator::ForEach(nsDequeFunctor& aFunctor) const{
|
const void nsDequeIterator::ForEach(nsDequeFunctor& aFunctor) const{
|
||||||
return mDeque.ForEach(aFunctor);
|
mDeque.ForEach(aFunctor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call this method when you wanto to iterate all the
|
||||||
|
* members of the container, passing a functor along
|
||||||
|
* to call your code.
|
||||||
|
*
|
||||||
|
* @update gess4/20/98
|
||||||
|
* @param aFunctor object to call for each member
|
||||||
|
* @return *this
|
||||||
|
*/
|
||||||
|
const void* nsDequeIterator::FirstThat(nsDequeFunctor& aFunctor) const{
|
||||||
|
return mDeque.FirstThat(aFunctor);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* conduct automated self test for this class
|
* conduct automated self test for this class
|
||||||
|
|
|
@ -102,6 +102,15 @@ friend class nsDequeIterator;
|
||||||
* @return ptr to first item in container
|
* @return ptr to first item in container
|
||||||
*/
|
*/
|
||||||
void* Pop(void);
|
void* Pop(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return topmost item without removing it.
|
||||||
|
*
|
||||||
|
* @update gess4/18/98
|
||||||
|
* @param none
|
||||||
|
* @return ptr to first item in container
|
||||||
|
*/
|
||||||
|
void* Peek(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove and return the last item in the container.
|
* Remove and return the last item in the container.
|
||||||
|
@ -157,7 +166,19 @@ friend class nsDequeIterator;
|
||||||
* @param aFunctor object to call for each member
|
* @param aFunctor object to call for each member
|
||||||
* @return *this
|
* @return *this
|
||||||
*/
|
*/
|
||||||
const void* ForEach(nsDequeFunctor& aFunctor) const;
|
const void ForEach(nsDequeFunctor& aFunctor) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call this method when you wanto to iterate all the
|
||||||
|
* members of the container, passing a functor along
|
||||||
|
* to call your code. This process will interupt if
|
||||||
|
* your function returns a null to this iterator.
|
||||||
|
*
|
||||||
|
* @update gess4/20/98
|
||||||
|
* @param aFunctor object to call for each member
|
||||||
|
* @return *this
|
||||||
|
*/
|
||||||
|
const void* FirstThat(nsDequeFunctor& aFunctor) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Perform automated selftest on the deque
|
* Perform automated selftest on the deque
|
||||||
|
@ -346,8 +367,19 @@ public:
|
||||||
* @param aFunctor object to call for each member
|
* @param aFunctor object to call for each member
|
||||||
* @return *this
|
* @return *this
|
||||||
*/
|
*/
|
||||||
const void* ForEach(nsDequeFunctor& aFunctor) const;
|
const void ForEach(nsDequeFunctor& aFunctor) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call this method when you wanto to iterate all the
|
||||||
|
* members of the container, passing a functor along
|
||||||
|
* to call your code.
|
||||||
|
*
|
||||||
|
* @update gess4/20/98
|
||||||
|
* @param aFunctor object to call for each member
|
||||||
|
* @return *this
|
||||||
|
*/
|
||||||
|
const void* FirstThat(nsDequeFunctor& aFunctor) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
PRInt32 mIndex;
|
PRInt32 mIndex;
|
||||||
const nsDeque& mDeque;
|
const nsDeque& mDeque;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче