inc/spaceSaver.h File Reference

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  spaceSaver
struct  spaceNode
struct  spaceRowTracker

Functions

spaceSaverspaceSaverMaxCellsNew (int winStart, int winEnd, int maxRows, int maxCells)
spaceSaverspaceSaverNew (int winStart, int winEnd, int maxRows)
void spaceSaverFree (struct spaceSaver **pSs)
spaceNodespaceSaverAdd (struct spaceSaver *ss, int start, int end, void *val)
spaceNodespaceSaverAddOverflow (struct spaceSaver *ss, int start, int end, void *val, boolean allowOverflow)
void spaceSaverFinish (struct spaceSaver *ss)


Function Documentation

struct spaceNode* spaceSaverAdd ( struct spaceSaver ss,
int  start,
int  end,
void *  val 
) [read]

Definition at line 133 of file spaceSaver.c.

References FALSE, spaceSaverAddOverflow(), and ss.

00137 {
00138 return spaceSaverAddOverflow(ss, start, end, val, FALSE);
00139 }

Here is the call graph for this function:

struct spaceNode* spaceSaverAddOverflow ( struct spaceSaver ss,
int  start,
int  end,
void *  val,
boolean  allowOverflow 
) [read]

Definition at line 63 of file spaceSaver.c.

References allClear(), AllocVar, needMem(), spaceRowTracker::next, round, spaceNode::row, slAddHead, slAddTail(), ss, TRUE, spaceRowTracker::used, and spaceNode::val.

Referenced by spaceSaverAdd().

00068 {
00069 int cellStart, cellEnd, cellWidth;
00070 struct spaceRowTracker *srt, *freeSrt = NULL;
00071 int rowIx = 0;
00072 struct spaceNode *sn;
00073 
00074 if (ss->isFull)
00075     return NULL;
00076 
00077 if ((start -= ss->winStart) < 0)
00078     start = 0;
00079 end -= ss->winStart;    /* We'll clip this in cell coordinates. */
00080 
00081 cellStart = round(start * ss->scale);
00082 cellEnd = round(end * ss->scale)+1;
00083 if (cellEnd > ss->cellsInRow)
00084     cellEnd = ss->cellsInRow;
00085 cellWidth = cellEnd - cellStart;
00086 
00087 /* Find free row. */
00088 for (srt = ss->rowList; srt != NULL; srt = srt->next)
00089     {
00090     if (allClear(srt->used + cellStart, cellWidth))
00091         {
00092         freeSrt = srt;
00093         break;
00094         }
00095     ++rowIx;
00096     }
00097 
00098 /* If no free row make new row. */
00099 if (freeSrt == NULL)
00100     {
00101     if (ss->rowCount >= ss->maxRows)
00102         {
00103         /* Abort if too many rows and no
00104            overflow allowed. */
00105         if(!allowOverflow) 
00106             {
00107             ss->isFull = TRUE;
00108             return NULL;
00109             }
00110         }
00111     else 
00112         {
00113         AllocVar(freeSrt);
00114         freeSrt->used = needMem(ss->cellsInRow);
00115         slAddTail(&ss->rowList, freeSrt);
00116         ++ss->rowCount;
00117         }
00118     }
00119 
00120 /* Mark that part of row used (except in overflow case). */
00121 if(freeSrt != NULL)
00122     memset(freeSrt->used + cellStart, 1, cellWidth);
00123 
00124 /* Make a space node. If allowing overflow it will
00125  all end up in the last row. */
00126 AllocVar(sn);
00127 sn->row = rowIx;
00128 sn->val = val;
00129 slAddHead(&ss->nodeList, sn);
00130 return sn;
00131 }

Here is the call graph for this function:

Here is the caller graph for this function:

void spaceSaverFinish ( struct spaceSaver ss  ) 

Definition at line 141 of file spaceSaver.c.

References slReverse(), and ss.

00143 {
00144 slReverse(&ss->nodeList);
00145 }

Here is the call graph for this function:

void spaceSaverFree ( struct spaceSaver **  pSs  ) 

Definition at line 38 of file spaceSaver.c.

References freeMem(), freez(), spaceRowTracker::next, slFreeList(), ss, and spaceRowTracker::used.

00040 {
00041 struct spaceSaver *ss = *pSs;
00042 if (ss != NULL)
00043     {
00044     struct spaceRowTracker *srt;
00045     for (srt = ss->rowList; srt != NULL; srt = srt->next)
00046         freeMem(srt->used);
00047     slFreeList(&ss->rowList);
00048     slFreeList(&ss->nodeList);
00049     freez(pSs);
00050     }
00051 }

Here is the call graph for this function:

struct spaceSaver* spaceSaverMaxCellsNew ( int  winStart,
int  winEnd,
int  maxRows,
int  maxCells 
) [read]

Definition at line 14 of file spaceSaver.c.

References AllocVar, and ss.

Referenced by spaceSaverNew().

00016 {
00017 struct spaceSaver *ss;
00018 float winWidth;
00019 
00020 AllocVar(ss);
00021 ss->winStart = winStart;
00022 ss->winEnd = winEnd;
00023 ss->maxRows = maxRows;
00024 winWidth = winEnd - winStart;
00025 ss->cellsInRow = winWidth;
00026 while (ss->cellsInRow > maxCells)
00027     ss->cellsInRow /= 2;
00028 ss->scale = ss->cellsInRow/winWidth;
00029 return ss;
00030 }

Here is the caller graph for this function:

struct spaceSaver* spaceSaverNew ( int  winStart,
int  winEnd,
int  maxRows 
) [read]

Definition at line 32 of file spaceSaver.c.

References spaceSaverMaxCellsNew().

00034 {
00035 return spaceSaverMaxCellsNew(winStart, winEnd, maxRows, 800);
00036 }

Here is the call graph for this function:


Generated on Tue Dec 25 19:15:38 2007 for blat by  doxygen 1.5.2