84 #define forall_arrayindices(i, A) \
85 for(i = (A).low(); i<=(A).high(); ++i)
93 #define forall_rev_arrayindices(i, A) \
94 for(i = (A).high(); i>=(A).low(); --i)
106 template<
class E,
class INDEX =
int>
class Array {
127 Array(INDEX a, INDEX b,
const E &x) {
218 void init(INDEX a, INDEX b,
const E &x) {
239 void fill(INDEX i, INDEX j,
const E &x) {
254 void grow(INDEX add,
const E &x);
261 void grow(INDEX add);
264 void permute (INDEX l, INDEX r);
285 template<
class COMPARER>
312 for(i =
size(); i-->0;)
322 template<
class COMPARER>
325 for(i =
size(); i-->0;)
326 if(comp.equal(e,
m_pStart[i]))
break;
344 template<
class COMPARER>
356 template<
class COMPARER>
357 void quicksort(INDEX l, INDEX r,
const COMPARER &comp) {
389 template<
class COMPARER>
395 for (E *pI = pL+1; pI <= pR; pI++) {
398 while (--pJ >= pL && comp.less(v,*pJ)) {
406 E *pI = pL, *pJ = pR;
410 while (comp.less(*pI,x)) pI++;
411 while (comp.less(x,*pJ)) pJ--;
426 template<
class E,
class INDEX>
429 INDEX sOld = size(), sNew = sOld + add;
433 E *p = (E *)realloc(m_pStart, sNew*
sizeof(E));
437 m_pStart = (E *)malloc(sNew*
sizeof(E));
441 m_vpStart = m_pStart-m_low;
442 m_pStop = m_pStart+sNew;
446 for (E *pDest = m_pStart+sOld; pDest < m_pStop; pDest++)
451 template<
class E,
class INDEX>
454 INDEX sOld = size(), sNew = sOld + add;
458 E *p = (E *)realloc(m_pStart, sNew*
sizeof(E));
462 m_pStart = (E *)malloc(sNew*
sizeof(E));
466 m_vpStart = m_pStart-m_low;
467 m_pStop = m_pStart+sNew;
471 for (E *pDest = m_pStart+sOld; pDest < m_pStop; pDest++)
475 template<
class E,
class INDEX>
478 m_low = a; m_high = b;
482 m_pStart = m_vpStart = m_pStop = 0;
485 m_pStart = (E *)malloc(s*
sizeof(E));
488 m_vpStart = m_pStart - a;
489 m_pStop = m_pStart + s;
494 template<
class E,
class INDEX>
499 for (; pDest < m_pStop; pDest++)
502 while(--pDest >= m_pStart)
510 template<
class E,
class INDEX>
515 for (; pDest < m_pStop; pDest++)
518 while(--pDest >= m_pStart)
526 template<
class E,
class INDEX>
530 for (E *pDest = m_pStart; pDest < m_pStop; pDest++)
537 template<
class E,
class INDEX>
545 while(pDest > m_pStart)
547 new (--pDest) E(*--pSrc);
553 template<
class E,
class INDEX>
559 E *pI = m_vpStart+l, *pStart = m_vpStart+l, *pStop = m_vpStart+r;
566 template<
class E,
class INDEX>
569 for (
int i = a.
low(); i <= a.
high(); i++) {
570 if (i > a.
low()) os << delim;
577 template<
class E,
class INDEX>
578 ostream &operator<<(ostream &os, const ogdf::Array<E,INDEX> &a)