@@ -7,156 +7,115 @@ namespace LightningDB
7
7
{
8
8
public static class LightningCursorMoveExtensions
9
9
{
10
- private static CursorGetByOperation CursorMoveBy ( LightningCursor cur , Func < KeyValuePair < byte [ ] , byte [ ] > ? > mover )
11
- {
12
- return new CursorGetByOperation ( cur , mover . Invoke ( ) ) ;
13
- }
14
-
15
- private static GetByOperation CursorMoveValueBy ( LightningCursor cur , Func < byte [ ] > mover )
16
- {
17
- return new GetByOperation ( cur . Database , mover . Invoke ( ) ) ;
18
- }
19
-
20
- private static bool CursorMove < TKey , TValue > ( LightningCursor cur , Func < KeyValuePair < byte [ ] , byte [ ] > ? > mover , out KeyValuePair < TKey , TValue > pair )
21
- {
22
- var op = CursorMoveBy ( cur , mover ) ;
23
-
24
- if ( ! op . PairExists )
25
- {
26
- pair = default ( KeyValuePair < TKey , TValue > ) ;
27
- return false ;
28
- }
29
- else
30
- {
31
- pair = op . Pair < TKey , TValue > ( ) ;
32
- return true ;
33
- }
34
- }
35
-
36
- private static bool CursorMoveValue < TValue > ( LightningCursor cur , Func < byte [ ] > mover , out TValue value )
37
- {
38
- var op = CursorMoveValueBy ( cur , mover ) ;
39
-
40
- if ( op == null )
41
- {
42
- value = default ( TValue ) ;
43
- return false ;
44
- }
45
- else
46
- {
47
- value = op . Value < TValue > ( ) ;
48
- return true ;
49
- }
50
- }
51
10
52
11
public static CursorGetByOperation MoveToFirstBy ( this LightningCursor cur )
53
12
{
54
- return CursorMoveBy ( cur , cur . MoveToFirst ) ;
13
+ return cur . CursorMoveBy ( cur . MoveToFirst ) ;
55
14
}
56
15
57
16
public static bool MoveToFirst < TKey , TValue > ( this LightningCursor cur , out KeyValuePair < TKey , TValue > pair )
58
17
{
59
- return CursorMove < TKey , TValue > ( cur , cur . MoveToFirst , out pair ) ;
18
+ return cur . CursorMove < TKey , TValue > ( cur . MoveToFirst , out pair ) ;
60
19
}
61
20
62
21
public static CursorGetByOperation MoveToLastBy ( this LightningCursor cur )
63
22
{
64
- return CursorMoveBy ( cur , cur . MoveToLast ) ;
23
+ return cur . CursorMoveBy ( cur . MoveToLast ) ;
65
24
}
66
25
67
26
public static bool MoveToLast < TKey , TValue > ( this LightningCursor cur , out KeyValuePair < TKey , TValue > pair )
68
27
{
69
- return CursorMove < TKey , TValue > ( cur , cur . MoveToLast , out pair ) ;
28
+ return cur . CursorMove < TKey , TValue > ( cur . MoveToLast , out pair ) ;
70
29
}
71
30
72
31
public static CursorGetByOperation GetCurrentBy ( this LightningCursor cur )
73
32
{
74
- return CursorMoveBy ( cur , cur . GetCurrent ) ;
33
+ return cur . CursorMoveBy ( cur . GetCurrent ) ;
75
34
}
76
35
77
36
public static bool GetCurrent < TKey , TValue > ( this LightningCursor cur , out KeyValuePair < TKey , TValue > pair )
78
37
{
79
- return CursorMove < TKey , TValue > ( cur , cur . GetCurrent , out pair ) ;
38
+ return cur . CursorMove < TKey , TValue > ( cur . GetCurrent , out pair ) ;
80
39
}
81
40
82
41
public static CursorGetByOperation MoveNextBy ( this LightningCursor cur )
83
42
{
84
- return CursorMoveBy ( cur , cur . MoveNext ) ;
43
+ return cur . CursorMoveBy ( cur . MoveNext ) ;
85
44
}
86
45
87
46
public static bool MoveNext < TKey , TValue > ( this LightningCursor cur , out KeyValuePair < TKey , TValue > pair )
88
47
{
89
- return CursorMove < TKey , TValue > ( cur , cur . MoveNext , out pair ) ;
48
+ return cur . CursorMove < TKey , TValue > ( cur . MoveNext , out pair ) ;
90
49
}
91
50
92
51
public static CursorGetByOperation MoveNextDuplicateBy ( this LightningCursor cur )
93
52
{
94
- return CursorMoveBy ( cur , cur . MoveNextDuplicate ) ;
53
+ return cur . CursorMoveBy ( cur . MoveNextDuplicate ) ;
95
54
}
96
55
97
56
public static bool MoveNextDuplicate < TKey , TValue > ( this LightningCursor cur , out KeyValuePair < TKey , TValue > pair )
98
57
{
99
- return CursorMove < TKey , TValue > ( cur , cur . MoveNextDuplicate , out pair ) ;
58
+ return cur . CursorMove < TKey , TValue > ( cur . MoveNextDuplicate , out pair ) ;
100
59
}
101
60
102
61
public static CursorGetByOperation MoveNextNoDuplicateBy ( this LightningCursor cur )
103
62
{
104
- return CursorMoveBy ( cur , cur . MoveNextNoDuplicate ) ;
63
+ return cur . CursorMoveBy ( cur . MoveNextNoDuplicate ) ;
105
64
}
106
65
107
66
public static bool MoveNextNoDuplicate < TKey , TValue > ( this LightningCursor cur , out KeyValuePair < TKey , TValue > pair )
108
67
{
109
- return CursorMove < TKey , TValue > ( cur , cur . MoveNextNoDuplicate , out pair ) ;
68
+ return cur . CursorMove < TKey , TValue > ( cur . MoveNextNoDuplicate , out pair ) ;
110
69
}
111
70
112
71
public static CursorGetByOperation MovePrevBy ( this LightningCursor cur )
113
72
{
114
- return CursorMoveBy ( cur , cur . MovePrev ) ;
73
+ return cur . CursorMoveBy ( cur . MovePrev ) ;
115
74
}
116
75
117
76
public static bool MovePrev < TKey , TValue > ( this LightningCursor cur , out KeyValuePair < TKey , TValue > pair )
118
77
{
119
- return CursorMove < TKey , TValue > ( cur , cur . MovePrev , out pair ) ;
78
+ return cur . CursorMove < TKey , TValue > ( cur . MovePrev , out pair ) ;
120
79
}
121
80
122
81
public static CursorGetByOperation MovePrevDuplicateBy ( this LightningCursor cur )
123
82
{
124
- return CursorMoveBy ( cur , cur . MovePrevDuplicate ) ;
83
+ return cur . CursorMoveBy ( cur . MovePrevDuplicate ) ;
125
84
}
126
85
127
86
public static bool MovePrevDuplicate < TKey , TValue > ( this LightningCursor cur , out KeyValuePair < TKey , TValue > pair )
128
87
{
129
- return CursorMove < TKey , TValue > ( cur , cur . MovePrevDuplicate , out pair ) ;
88
+ return cur . CursorMove < TKey , TValue > ( cur . MovePrevDuplicate , out pair ) ;
130
89
}
131
90
132
91
public static CursorGetByOperation MovePrevNoDuplicateBy ( this LightningCursor cur )
133
92
{
134
- return CursorMoveBy ( cur , cur . MovePrevNoDuplicate ) ;
93
+ return cur . CursorMoveBy ( cur . MovePrevNoDuplicate ) ;
135
94
}
136
95
137
96
public static bool MovePrevNoDuplicate < TKey , TValue > ( this LightningCursor cur , out KeyValuePair < TKey , TValue > pair )
138
97
{
139
- return CursorMove < TKey , TValue > ( cur , cur . MovePrevNoDuplicate , out pair ) ;
98
+ return cur . CursorMove < TKey , TValue > ( cur . MovePrevNoDuplicate , out pair ) ;
140
99
}
141
100
142
101
public static GetByOperation MoveToFirstDuplicateBy ( this LightningCursor cur )
143
102
{
144
- return CursorMoveValueBy ( cur , cur . MoveToFirstDuplicate ) ;
103
+ return cur . CursorMoveValueBy ( cur . MoveToFirstDuplicate ) ;
145
104
}
146
105
147
106
public static bool MoveToFirstDuplicate < TValue > ( this LightningCursor cur , out TValue value )
148
107
{
149
- return CursorMoveValue < TValue > ( cur , cur . MoveToFirstDuplicate , out value ) ;
108
+ return cur . CursorMoveValue < TValue > ( cur . MoveToFirstDuplicate , out value ) ;
150
109
}
151
110
152
111
public static GetByOperation MoveToLastDuplicateBy ( this LightningCursor cur )
153
112
{
154
- return CursorMoveValueBy ( cur , cur . MoveToLastDuplicate ) ;
113
+ return cur . CursorMoveValueBy ( cur . MoveToLastDuplicate ) ;
155
114
}
156
115
157
116
public static bool MoveToLastDuplicate < TValue > ( this LightningCursor cur , out TValue value )
158
117
{
159
- return CursorMoveValue < TValue > ( cur , cur . MoveToLastDuplicate , out value ) ;
118
+ return cur . CursorMoveValue < TValue > ( cur . MoveToLastDuplicate , out value ) ;
160
119
}
161
120
162
121
}
0 commit comments