Back to index

lightning-sunbird  0.9+nobinonly
Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes
nsIntervalSet Class Reference

#include <nsIntervalSet.h>

Collaboration diagram for nsIntervalSet:
Collaboration graph
[legend]

List of all members.

Classes

class  Interval

Public Types

typedef nscoord coord_type

Public Member Functions

 nsIntervalSet (IntervalSetAlloc aAlloc, IntervalSetFree aFree, void *aAllocatorClosure)
 ~nsIntervalSet ()
void IncludeInterval (coord_type aBegin, coord_type aEnd)
PRBool HasPoint (coord_type aPoint) const
PRBool Intersects (coord_type aBegin, coord_type aEnd) const
PRBool Contains (coord_type aBegin, coord_type aEnd) const
PRBool IsEmpty () const

Private Member Functions

void FreeInterval (Interval *aInterval)

Private Attributes

IntervalmList
IntervalSetAlloc mAlloc
IntervalSetFree mFree
voidmAllocatorClosure

Detailed Description

Definition at line 56 of file nsIntervalSet.h.


Member Typedef Documentation

Definition at line 60 of file nsIntervalSet.h.


Constructor & Destructor Documentation

nsIntervalSet::nsIntervalSet ( IntervalSetAlloc  aAlloc,
IntervalSetFree  aFree,
void aAllocatorClosure 
)

Definition at line 42 of file nsIntervalSet.cpp.

    : mList(nsnull),
      mAlloc(aAlloc),
      mFree(aFree),
      mAllocatorClosure(aAllocatorClosure)
{
    NS_ASSERTION(mAlloc && mFree, "null callback params");
}

Definition at line 52 of file nsIntervalSet.cpp.

{
    Interval *current = mList;
    while (current) {
        Interval *trash = current;
        current = current->mNext;
        FreeInterval(trash);
    }
}

Here is the call graph for this function:


Member Function Documentation

PRBool nsIntervalSet::Contains ( coord_type  aBegin,
coord_type  aEnd 
) const

Definition at line 118 of file nsIntervalSet.cpp.

{
    Interval *current = mList;
    while (current && current->mBegin <= aBegin) {
        if (current->mEnd >= aEnd)
            return PR_TRUE;
        current = current->mNext;
    }
    return PR_FALSE;
}

Definition at line 62 of file nsIntervalSet.cpp.

{
    NS_ASSERTION(aInterval, "null interval");

    aInterval->Interval::~Interval();
    (*mFree)(sizeof(Interval), aInterval, mAllocatorClosure);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 96 of file nsIntervalSet.cpp.

{
    Interval *current = mList;
    while (current && current->mBegin <= aPoint) {
        if (current->mEnd >= aPoint)
            return PR_TRUE;
        current = current->mNext;
    }
    return PR_FALSE;
}

Definition at line 70 of file nsIntervalSet.cpp.

{
    Interval *newInterval = NS_STATIC_CAST(Interval*,
                               (*mAlloc)(sizeof(Interval), mAllocatorClosure));
    if (!newInterval) {
        NS_NOTREACHED("allocation failure");
        return;
    }
    new(newInterval) Interval(aBegin, aEnd);

    Interval **current = &mList;
    while (*current && (*current)->mEnd < aBegin)
        current = &(*current)->mNext;

    newInterval->mNext = *current;
    *current = newInterval;

    Interval *subsumed = newInterval->mNext;
    while (subsumed && subsumed->mBegin <= aEnd) {
        newInterval->mEnd = PR_MAX(newInterval->mEnd, subsumed->mEnd);
        newInterval->mNext = subsumed->mNext;
        FreeInterval(subsumed);
        subsumed = newInterval->mNext;
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool nsIntervalSet::Intersects ( coord_type  aBegin,
coord_type  aEnd 
) const

Definition at line 107 of file nsIntervalSet.cpp.

{
    Interval *current = mList;
    while (current && current->mBegin <= aEnd) {
        if (current->mEnd >= aBegin)
            return PR_TRUE;
        current = current->mNext;
    }
    return PR_FALSE;
}

Here is the caller graph for this function:

PRBool nsIntervalSet::IsEmpty ( void  ) const [inline]

Definition at line 93 of file nsIntervalSet.h.

    {
        return !mList;
    }

Here is the caller graph for this function:


Member Data Documentation

IntervalSetAlloc nsIntervalSet::mAlloc [private]

Definition at line 120 of file nsIntervalSet.h.

Definition at line 122 of file nsIntervalSet.h.

IntervalSetFree nsIntervalSet::mFree [private]

Definition at line 121 of file nsIntervalSet.h.

Definition at line 119 of file nsIntervalSet.h.


The documentation for this class was generated from the following files: