Closed DanielZambSB closed 4 months ago
Q
I
[0, N)
P
[0, tp)
i
0 <= i < tp
P[i]
>
>(P,i)
P[i+1]
+1
<
<(P,i)
P[i-1]
-1
ps
{5, 10, 20, 50, 100}
tp
tp = Math.ceil(I.length / ps)
gps
gps = 3
tgp
tgp = Math.ceil(tp / gps)
j
PG[j]
PG
[0,tgp)
showPages(Q)
tp := Math.ceil(I.length / ps)
tgp := Math.ceil(tp / gps)
r := tp % gps
direction > 0
j=tgp-1
r > 0
offset := j*gps
0 <= k < r
P[offset+k]
Page(Q)
i % gps == 0
j := j+1
P[offset]
0<=i<3, P[offset+i]
direction < 0
i % gps = gps-1
j:=j-1
[Q]
i = 0
i = tp - 1
> (P, i)
i := i+1
[i*ps, (i+1)*ps)
table
(3)
< (P, i)
i := i-1
full pagination algorithm implemented, quedo ready esta vuelta!!!
Pagination Algorithms
Variables and Definitions
Q
I
: Array of inquirys with size[0, N)
P
: Pagination Array of pages with size[0, tp)
i
: Current index over P,0 <= i < tp
P[i]
: Page at indexi
,P[i]
inP
>
: Next page,>(P,i)
results inP[i+1]
, and changes direction to+1
<
: Previous page,<(P,i)
results inP[i-1]
, and changes direction to-1
ps
: Page sizes,{5, 10, 20, 50, 100}
tp
: Total pages, calculated astp = Math.ceil(I.length / ps)
gps
: Group of pages size,gps = 3
tgp
: Total group of pages calculated astgp = Math.ceil(tp / gps)
j
: Current index over a page groupPG[j]
: page group at indexj
,PG[j]
inPG
PG
: pagination "array" of group of pages with size[0,tgp)
Functions
showPages(Q)
tp := Math.ceil(I.length / ps)
tgp := Math.ceil(tp / gps)
r := tp % gps
direction > 0
j=tgp-1
andr > 0
:offset := j*gps
0 <= k < r
size widgetP[offset+k]
Page(Q)
i % gps == 0
:j := j+1
offset := j*gps
PG[j]
andP[offset]
0<=i<3, P[offset+i]
Page(Q)
direction < 0
i % gps = gps-1
:j:=j-1
offset := j*gps
PG[j]
andP[offset]
0<=i<3, P[offset+i]
Page(Q)
Page
[Q]
i = 0
then<
i = tp - 1
>
P[i]
as current> (P, i)
i := i+1
P[i]
I
from[i*ps, (i+1)*ps)
table
(3)
< (P, i)
i := i-1
P[i]
I
from[i*ps, (i+1)*ps)
table
(3)
Additional Notes
gps
is the number of page indices to show at once.tp
is the total number of pages, andps
is the current page size.i
is the index of the current page.[i*ps, (i+1)*ps)
indicates the range of indices from the inputI
to be displayed on the current page.