-
Notifications
You must be signed in to change notification settings - Fork 1
/
stack.h
52 lines (35 loc) · 1.25 KB
/
stack.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// copri, Attacking RSA by factoring coprimes
//
// License: GNU Lesser General Public License (LGPL), version 3 or later
// See the lgpl.txt file in the root directory or <https://www.gnu.org/licenses/lgpl>.
#ifndef STACK_H_
#define STACK_H_
typedef struct mpz_stack_node_ {
mpz_t val;
struct mpz_stack_node_* next;
} mpz_stack_node;
typedef struct mpz_stack_ {
mpz_stack_node *top;
size_t size;
} mpz_stack;
void mpz_stack_init(mpz_stack **s);
void mpz_stack_clear(mpz_stack *s);
int mpz_stack_push(mpz_stack *s, mpz_t val);
int mpz_stack_pop(mpz_stack *s, mpz_t val);
int mpz_stack_top(mpz_stack *s, mpz_t val);
typedef struct mpz_ui_pair_stack_node_ {
size_t a;
mpz_t b;
struct mpz_ui_pair_stack_node_* next;
} mpz_ui_pair_stack_node;
typedef struct mpz_ui_pair_stack_ {
mpz_ui_pair_stack_node *top;
size_t size;
} mpz_ui_pair_stack;
void mpz_ui_pair_stack_init(mpz_ui_pair_stack **s);
void mpz_ui_pair_stack_clear(mpz_ui_pair_stack *s);
int mpz_ui_pair_stack_push(mpz_ui_pair_stack *s, size_t a, mpz_t b);
int mpz_ui_pair_stack_pop(mpz_ui_pair_stack *s, size_t *a, mpz_t b);
int mpz_ui_pair_stack_top(mpz_ui_pair_stack *s, size_t *a, mpz_t b);
int mpz_ui_pair_stack_top_a(mpz_ui_pair_stack *s, size_t *a);
#endif /* STACK_H_ */