OSDN Git Service

Hulk did something
[bytom/vapor.git] / api / page_util.go
diff --git a/api/page_util.go b/api/page_util.go
new file mode 100644 (file)
index 0000000..7bffbc0
--- /dev/null
@@ -0,0 +1,18 @@
+package api
+
+// Get the start and end of the page.
+func getPageRange(size int, from uint, count uint) (uint, uint) {
+       total := uint(size)
+       if from == 0 && count == 0 {
+               return 0, total
+       }
+       start := from
+       end := from + count
+       if start > total {
+               start = total
+       }
+       if end > total {
+               end = total
+       }
+       return start, end
+}