@@ -8,22 +8,59 @@ signature with length of 4096 bits to represent sets).
88
99All work was done by Teodor Sigaev (teodor@stack.net) and Oleg Bartunov
1010(oleg@sai.msu.su). See http://www.sai.msu.su/~megera/postgres/gist
11- for additional information. Andrey Oktyabrskihas done a great work on
11+ for additional information. Andrey Oktyabrskidid a great work on
1212adding new functions and operations.
1313
1414
1515FUNCTIONS:
1616
1717 int icount(int[]) - the number of elements in intarray
18+
19+ test=# select icount('{1,2,3}'::int[]);
20+ icount
21+ --------
22+ 3
23+ (1 row)
24+
1825 int[] sort(int[], 'asc' | 'desc') - sort intarray
26+
27+ test=# select sort('{1,2,3}'::int[],'desc');
28+ sort
29+ ---------
30+ {3,2,1}
31+ (1 row)
32+
1933 int[] sort(int[]) - sort in ascending order
2034 int[] sort_asc(int[]),sort_desc(int[]) - shortcuts for sort
35+
2136 int[] uniq(int[]) - returns unique elements
37+
38+ test=# select uniq(sort('{1,2,3,2,1}'::int[]));
39+ uniq
40+ ---------
41+ {1,2,3}
42+ (1 row)
43+
2244 int idx(int[], int item) - returns index of first intarray matching element to item, or
2345 '0' if matching failed.
46+
47+ test=# select idx('{1,2,3,2,1}'::int[],2);
48+ idx
49+ -----
50+ 2
51+ (1 row)
52+
53+
2454 int[] subarray(int[],int START [, int LEN]) - returns part of intarray starting from
2555 element number START (from 1) and length LEN.
2656
57+ test=# select subarray('{1,2,3,2,1}'::int[],2,3);
58+ subarray
59+ ----------
60+ {2,3,2}
61+ (1 row)
62+
63+
2764OPERATIONS:
2865
2966 int[] && int[] - overlap - returns TRUE if arrays has at least one common elements.
@@ -33,7 +70,7 @@ OPERATIONS:
3370 int[] + int - push element to array ( add to end of array)
3471 int[] + int[] - merge of arrays (right array added to the end of left one)
3572 int[] - int - remove entries matched by right argument from array
36- int[] - int[] - removeleft array fromright
73+ int[] - int[] - removeright array fromleft
3774 int[] | int - returns intarray - union of arguments
3875 int[] | int[] - returns intarray as a union of two arrays
3976 int[] & int[] - returns intersection of arrays