Uniot Docs
  • Introduction
  • Guides
    • Getting Started
    • Uniot Badge
    • Device Network
  • Foundations
    • Edge Logic Deployment
  • General Concepts
    • Primitives
    • Scripting
  • Platform
    • Dashboard
    • Sandbox
      • Visual Editor
        • Special
        • Logic
        • Math
        • Loops
        • Text
        • Variables
        • Functions
        • Primitives
      • Logger
      • Emulator
      • Control Panel
  • Advanced
    • Uniot Core
      • Scheduler
        • TaskScheduler
        • IExecutor
        • ISchedulerConnectionKit
        • Task
        • SchedulerTask
      • AppKit
        • AppKit
        • LispDevice
        • LispPrimitives
        • TopDevice
      • CBORWrapper
        • CBORObject
        • COSE
        • COSEMessage
        • ICOSESigner
      • Date
        • Date
        • SimpleNTP
      • EventBus
        • EventBus
        • IEventBusConnectionKit
        • DataChannels
        • EventEmitter
        • EventListener
        • EventEntity
        • CallbackEventListener
      • Hardware
        • Button
      • LispWrapper
        • DefaultPrimitives
        • LispHelper
        • PrimitiveExpeditor
        • unLisp
      • MQTTWrapper
        • CallbackMQTTDevice
        • MQTTDevice
        • MQTTKit
        • MQTTPath
      • Network
        • ConfigCaptivePortal
        • NetworkController
        • NetworkScheduler
      • Register
        • GpioRegister
        • ObjectRegister
        • ObjectRegisterRecord
        • Register
        • RegisterManager
        • RegisterManagerProxy
      • Storage
        • CBORStorage
        • CrashStorage
        • Storage
        • WifiStorage
      • Utils
        • Array
        • Bytes
        • ClearQueue
        • IterableQueue
        • LimitedQueue
        • GlobalBufferMemoryManager
        • Map
        • Singleton
        • TypeId
      • Credentials
    • Uniot Lisp
      • Language Description
      • Embedding Instructions
  • API
    • MQTT Convention
Powered by GitBook
On this page
  • Purpose and Benefits
  • Class Methods
  1. Advanced
  2. Uniot Core
  3. Utils

ClearQueue

A Lightweight and Efficient Queue Implementation

The ClearQueue class is a templated, lightweight, and memory-efficient implementation of the queue data structure. Unlike the std::queue in the C++ standard library that often requires more resources, this class has been optimized for use in embedded systems like those used in the Uniot Core project.

Purpose and Benefits

  • Lightweight and Resource-Efficient: Being specially crafted for systems with limited resources, ClearQueue offers a simplified interface and consumes less memory.

  • Uniqueness Handling: Offers functionality to handle unique values in the queue.

  • Flexible Operations: Provides functions for adding, removing, inspecting, and iterating over the elements.

  • Error Handling: Offers a mechanism to provide error codes for certain operations, allowing for better control and robustness.

Class Methods

Constructor and Destructor:

  • ClearQueue(): Initializes the queue with empty states.

  • ~ClearQueue(): Cleans up the queue, releasing any allocated memory.

Push Operations:

  • push(const T value): Adds the specified value to the end of the queue.

  • pushUnique(const T value): Adds the value to the queue only if it doesn't already exist. Returns true if the value was added.

Pop and Peek Operations:

  • hardPop(): Removes and returns the front element from the queue without any checks.

  • hardPeek() const: Returns the front element without removing it.

  • pop(const T errorCode): Removes and returns the front element. If the queue is empty, it returns the provided error code.

  • peek(const T errorCode) const: Returns the front element without removing it. If the queue is empty, returns the provided error code.

Element Management:

  • removeOne(const T value): Removes the first occurrence of the specified value from the queue. Returns true if successful.

  • contains(const T value) const: Checks if the queue contains the specified value.

Queue State Checks:

  • isEmpty() const: Returns true if the queue is empty.

Iteration:

  • forEach(VoidCallback callback): Iterates over each element in the queue, executing the provided callback for each element.

PreviousBytesNextIterableQueue

Last updated 1 year ago