Index: ut_vector.h =================================================================== RCS file: /cvsroot/abi/src/af/util/xp/ut_vector.h,v retrieving revision 1.48 diff -u -r1.48 ut_vector.h --- ut_vector.h 27 Sep 2003 06:30:55 -0000 1.48 +++ ut_vector.h 30 Sep 2003 18:05:43 -0000 @@ -109,7 +109,8 @@ inline UT_uint32 getItemCount() const { return m_iCount; } UT_sint32 findItem(void*) const; - UT_sint32 insertItemAt(void*, UT_uint32 ndx); + UT_sint32 insertItemAt(const void*, UT_uint32 ndx); + UT_sint32 addItemSorted(const void* p, int (*compar)(const void *, const void *)); void deleteNthItem(UT_uint32 n); void clear(); void qsort(int (*compar)(const void *, const void *)); Index: ut_vector.cpp =================================================================== RCS file: /cvsroot/abi/src/af/util/xp/ut_vector.cpp,v retrieving revision 1.51 diff -u -r1.51 ut_vector.cpp --- ut_vector.cpp 27 Sep 2003 06:30:54 -0000 1.51 +++ ut_vector.cpp 30 Sep 2003 18:05:43 -0000 @@ -101,7 +101,7 @@ return 0; } -UT_sint32 UT_Vector::insertItemAt(void* p, UT_uint32 ndx) +UT_sint32 UT_Vector::insertItemAt(const void* p, UT_uint32 ndx) { if (ndx > m_iCount + 1) return -1; @@ -146,6 +146,25 @@ m_pEntries[m_iCount++] = (void *)p; /*** bad, cast away const so we can build again ***/ return 0; +} + +UT_sint32 UT_Vector::addItemSorted(const void* p, int (*compar)(const void *, const void *)) +{ + + if (!m_iCount) return addItem(p); + + UT_uint32 i = 0; + int icmp; + + icmp = compar(&p, &m_pEntries[i]); + + while ( icmp > 0 && i < m_iCount - 1) + { + i++; + icmp = compar(&p, &m_pEntries[i]); + } + + return insertItemAt( p, i ); } /** It returns true if there were no errors, false elsewhere */ Index: pp_TableAttrProp.cpp =================================================================== RCS file: /cvsroot/abi/src/text/ptbl/xp/pp_TableAttrProp.cpp,v retrieving revision 1.18 diff -u -r1.18 pp_TableAttrProp.cpp --- pp_TableAttrProp.cpp 27 Sep 2003 06:36:35 -0000 1.18 +++ pp_TableAttrProp.cpp 30 Sep 2003 18:38:23 -0000 @@ -83,9 +83,9 @@ *pSubscript = u; } pAP->setIndex(u); //$HACK - result = (m_vecTableSorted.addItem(pAP,NULL) == 0); + result = (m_vecTableSorted.addItemSorted(pAP,compareAP) == 0); } - sortTable(); + // sortTable(); return result; }