@@ -8,22 +8,59 @@ signature with length of 4096 bits to represent sets).
8
8
9
9
All work was done by Teodor Sigaev (teodor@stack.net) and Oleg Bartunov
10
10
(oleg@sai.msu.su). See http://www.sai.msu.su/~megera/postgres/gist
11
- for additional information. Andrey Oktyabrski has done a great work on
11
+ for additional information. Andrey Oktyabrski did a great work on
12
12
adding new functions and operations.
13
13
14
14
15
15
FUNCTIONS:
16
16
17
17
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
+
18
25
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
+
19
33
int[] sort(int[]) - sort in ascending order
20
34
int[] sort_asc(int[]),sort_desc(int[]) - shortcuts for sort
35
+
21
36
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
+
22
44
int idx(int[], int item) - returns index of first intarray matching element to item, or
23
45
'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
+
24
54
int[] subarray(int[],int START [, int LEN]) - returns part of intarray starting from
25
55
element number START (from 1) and length LEN.
26
56
57
+ test=# select subarray('{1,2,3,2,1}'::int[],2,3);
58
+ subarray
59
+ ----------
60
+ {2,3,2}
61
+ (1 row)
62
+
63
+
27
64
OPERATIONS:
28
65
29
66
int[] && int[] - overlap - returns TRUE if arrays has at least one common elements.
@@ -33,7 +70,7 @@ OPERATIONS:
33
70
int[] + int - push element to array ( add to end of array)
34
71
int[] + int[] - merge of arrays (right array added to the end of left one)
35
72
int[] - int - remove entries matched by right argument from array
36
- int[] - int[] - remove left array from right
73
+ int[] - int[] - remove right array from left
37
74
int[] | int - returns intarray - union of arguments
38
75
int[] | int[] - returns intarray as a union of two arrays
39
76
int[] & int[] - returns intersection of arrays
0 commit comments