This commit is contained in:
rickg%netscape.com 1998-08-05 01:59:34 +00:00
Родитель 86ea166dba
Коммит 3d3143056b
4 изменённых файлов: 168 добавлений и 10 удалений

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

@ -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

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

@ -103,6 +103,15 @@ friend class nsDequeIterator;
*/ */
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,7 +367,18 @@ 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;

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

@ -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

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

@ -103,6 +103,15 @@ friend class nsDequeIterator;
*/ */
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,7 +367,18 @@ 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;