Giter Site home page Giter Site logo

Comments (4)

digamesystems avatar digamesystems commented on July 30, 2024

I'm not sure how to pull an item out of the middle of the buffer, but you can choose whether or not to process an item at the time it's about to be dealt with.

In my application I'm queueing up messages to be sent to a server. If the attempt to sends them succeeds, I take the message out of the buffer. If it fails I hang onto it for a later attempt. (It's a mobile app where connectivity is spotty.)

Snippet from my code:

      String activeMessage = String(msgBuffer.first()->c_str());   // Read from the buffer without removing the data from it.
      
      messageACKed = sendReceiveLoRa(activeMessage, config); // Try to send the message over a wireless link

      ...

      if (messageACKed)   // Message sent and reply received. Take it off of the queue.
      {
        ...
        String  * entry = msgBuffer.shift(); // Pops the message off of the queue.
        delete entry;
        ...
     }

from circularbuffer.

guilhermeaiolfi avatar guilhermeaiolfi commented on July 30, 2024

But them I will need two queues: one to be processed and one to hold that items that shouldn't be processed. That doesn't look right. Anyway, I came up with a workaround that worked. It is basically looping thought all items and putting them back at the end of the buffer, except the one I want to remove. It seems good enough for the time being.

from circularbuffer.

digamesystems avatar digamesystems commented on July 30, 2024

from circularbuffer.

rlogiacco avatar rlogiacco commented on July 30, 2024

I don't see the feature you are requesting as something required on a circular buffer, thus I don't see it as a defect.
My reasoning is this is a buffer, not a data archive: the data are intended to be added and removed from the buffer, not manipulated "in place". Nothing prevents you to manipulate the data stored in the buffer, but the features you are requesting are intended for a list, a vector, an hashmap.... not a buffer.

from circularbuffer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.