Skip to content

Demonstration of technique of maintaining a queue inside storage without havingh separated queue object. May be useful for cases when you want to insert elements into storage as quickly as possible and do not want to creating new object and place them in queue.

Notifications You must be signed in to change notification settings

lsem/linked_queue

Repository files navigation

linked_queue

Demonstration of technique of maintaining a queue inside storage without havingh separated queue object. May be useful for cases when you want to insert elements into storage as quickly as possible and do not want to creating new object and place them in queue.

    First            Last
        |             |
        v             |
------------     -----|------     
|        o-|---> |    |-->o-|----> NULL
|          |     |          |     
------------     ------------     

Queuing next record for processing:

        1) *Last = &NEW;  

           First             Last
             |                |
             V                |
        ------------     -----|------     
        |        n-|---> |    |-->n |
        |          |     |        | |     
        ------------     ---------|--     
                                  |
                                  V
                             ------------
                             |   NEW  n-|--> NULL
                             |          |
                             ------------

        2) Last = &NEW->n;
           First             Last
             |                 |
             V                 ---------
        ------------     ------------  |   
        |        n-|---> |        n |  |
        |          |     |        | |  |  
        ------------     ---------|--  |  
                                  |    |
                                  V    |
                              ---------V--
                              |   NEW  n-|--> NULL
                              |          |
                              ------------

    ------------------------------------
    | Single item queue case:
    ------------------------------------

           First (T*)       Last (T**)
             |                |
             |  ---------------
             V  |
        --------V----    
        |       o--|---> NULL
        |          |     
        ------------     

About

Demonstration of technique of maintaining a queue inside storage without havingh separated queue object. May be useful for cases when you want to insert elements into storage as quickly as possible and do not want to creating new object and place them in queue.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published