! * \brief boxaaInsertBoxa() * * \param[in] baa * \param[in] index location in boxaa to insert new boxa * \param[in] boxa new boxa to be inserted * \return 0 if OK, 1 on error * * * Notes: * (1) This shifts boxa[i] --> boxa[i + 1] for all i >= index, * and then inserts boxa as boxa[index]. * (2) To insert at the beginning of the array, set index = 0
| 1687 | * </pre> |
| 1688 | */ |
| 1689 | l_int32 |
| 1690 | boxaaInsertBoxa(BOXAA *baa, |
| 1691 | l_int32 index, |
| 1692 | BOXA *boxa) |
| 1693 | { |
| 1694 | l_int32 i, n; |
| 1695 | BOXA **array; |
| 1696 | |
| 1697 | PROCNAME("boxaaInsertBoxa"); |
| 1698 | |
| 1699 | if (!baa) |
| 1700 | return ERROR_INT("baa not defined", procName, 1); |
| 1701 | n = boxaaGetCount(baa); |
| 1702 | if (index < 0 || index > n) |
| 1703 | return ERROR_INT("index not in {0...n}", procName, 1); |
| 1704 | if (!boxa) |
| 1705 | return ERROR_INT("boxa not defined", procName, 1); |
| 1706 | |
| 1707 | if (n >= baa->nalloc) |
| 1708 | boxaaExtendArray(baa); |
| 1709 | array = baa->boxa; |
| 1710 | baa->n++; |
| 1711 | for (i = n; i > index; i--) |
| 1712 | array[i] = array[i - 1]; |
| 1713 | array[index] = boxa; |
| 1714 | |
| 1715 | return 0; |
| 1716 | } |
| 1717 | |
| 1718 | |
| 1719 | /*! |
nothing calls this directly
no test coverage detected