From 7e58eadab1678d794344a0b14c7872296f585f96 Mon Sep 17 00:00:00 2001 From: tslil Date: Sat, 3 Jul 2021 16:17:27 -0400 Subject: experimenting with a lazy queue implementation presently it's not correct --- include/actions.h | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'include/actions.h') diff --git a/include/actions.h b/include/actions.h index 75c881e..54b9077 100644 --- a/include/actions.h +++ b/include/actions.h @@ -44,15 +44,12 @@ typedef uint32_t action_t; | (data0) << A_DATA0_SHIFT \ | (data1) << A_DATA1_SHIFT) -typedef struct action_node_s { - struct action_node_s *next; - action_t action; -} action_node_t; - -typedef struct action_list_s { - struct action_node_s *head, *tail; - uint32_t length; -} action_list_t; +// lazy queue +#define ACTION_AR_LEN 256 +typedef struct action_lq_s { + action_t actions[ACTION_AR_LEN*2]; + int length, i_f, i_b; +} action_lq_t; // =================================================================== // Variables @@ -64,11 +61,12 @@ extern int8_t move_deltas[4]; // Methods // =================================================================== -void action_list_init(void); -void action_list_free(action_list_t *list); -action_list_t *action_list_generate(void); +void action_lq_init(void); +void action_lq_free(action_lq_t *lq); +action_lq_t *action_lq_generate(void); +action_lq_t *action_lq_copy_with_mtf(action_lq_t *lq, action_t front); -int action_move_to_front(const action_t action, action_list_t *list); +int action_move_to_front(const action_t action, action_lq_t *lq); void action_take(const action_t action); void action_undo(const action_t action); -- cgit v1.2.3