diff options
| author | tslil <tslil@posteo.de> | 2021-07-03 16:17:27 -0400 |
|---|---|---|
| committer | tslil <tslil@posteo.de> | 2026-08-28 19:37:41 +0100 |
| commit | 7e58eadab1678d794344a0b14c7872296f585f96 (patch) | |
| tree | 452fc5adce15dadc6a703d93dd8894e473ca3060 /include/actions.h | |
| parent | 07c5dded49d5943f54cca0c75a7a93a30ee2f323 (diff) | |
experimenting with a lazy queue implementationlazy_queue
presently it's not correct
Diffstat (limited to 'include/actions.h')
| -rw-r--r-- | include/actions.h | 24 |
1 files changed, 11 insertions, 13 deletions
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); |
