MrAlek/PagedArray

Setting the PagedArray with an empty array hit the assert "Page index out of bounds"

alejandrogarin opened this issue · 5 comments

func testSetEmptyElementsFirstPage() {
    var emptyArray: PagedArray<Int> = PagedArray(count: 0, pageSize: 10)
    emptyArray.setElements(Array(), page: 0)
    XCTAssertEqual(emptyArray.lastPage, 0)
}

func testSetEmptyElementsFirstPageWithStartPage() {
    var emptyArray: PagedArray<Int> = PagedArray(count: 0, pageSize: 10, startPage:1)
    emptyArray.setElements(Array(), page: 1)
    XCTAssertEqual(emptyArray.lastPage, 1)
}

@alejandrogarin Did you easily find a work around for this?

I fixed the issue in my fork and added a couple of new features like reordering of elements. I don't think it was hard to fix.

Thanks, took a similar approach but nice improvements in your fork.

Sorry for being slow, buying a new apartment takes time! @alejandrogarin great job with your fork, you have some interesting changes which I'll look into.

I've now added support for empty arrays (f17695a). You can't set an empty page for a non-empty array yet though. I don't know if that even makes sense since you then can instead just change the size of the entire array (also a new feature).