DEV Community

Leo
Leo

Posted on

SO

so.hpp

#ifndef so_hpp
#define so_hpp

#include <iostream>
#include <assert.h>

class process {

    class node {

  char _id;
  int _time;
  int _priority;
  node *_next;

  public:

    node(char i, int t, int q);

  char id() const { return _id; } //cual es el id
  int tme() const { return _time; } //cual es el tiempo
  int prty() const { return _priority; } //cual es la prioridad
  node *next() const { return _next; } // cual es el siguiente apuntador
  void next(node *p) { _next = p; } // cambia el siguiente ap
  };

  int n; // Capacity of process
  int s; // Size of process

  node *head; // First item in queue
  node *tail; // Last item in queue

public:

  process(int);
  ~process();

  void push(int);
  int pop(void);

  int capacity() const { return n; }
  int size() const { return s; }

  bool full() const { return s==n; }
  bool empty() const { return s==0; }

  void print();
};

#endif /* so_hpp */
Enter fullscreen mode Exit fullscreen mode

so.cpp

#include "so.hpp"

  process::node::node(char i, int t, int q) {
      _id = i;
      _time = t;
      _priority = q;
      _next = nullptr;
  }

  process::process(int c){

      n = c;
      s = 0;
      head = nullptr;
      tail = nullptr;
  }

  process::~process(){

      while(head != nullptr) {

          node *p = head;
          head = head -> next();
          delete p;
      }
  }

  void process::push(char i, int t, int q){

      assert(!full());
    node *p = new node(i, t, q);
    if(empty()) {
        head = p;
        tail = p;
      }else{
        tail -> next(p);
        tail = p;
    }
    s++;
  }

  int process::pop(){

      assert(!empty());
          char i = head -> id();
          int t = head -> tme();
          int q = head -> prty();

          node *p = head;
          head = p -> next(); 
          delete p;
          s--;
          return x;
  }

  void process::print(){

      node *p = head;
      std::cout<<"[ ";
      while(p != nullptr){
      std::cout << p -> data() << " ";
      p = p -> next();
      }
  std::cout << "]" << std::endl;
}



Enter fullscreen mode Exit fullscreen mode

Quadratic AI

Quadratic AI – The Spreadsheet with AI, Code, and Connections

  • AI-Powered Insights: Ask questions in plain English and get instant visualizations
  • Multi-Language Support: Seamlessly switch between Python, SQL, and JavaScript in one workspace
  • Zero Setup Required: Connect to databases or drag-and-drop files straight from your browser
  • Live Collaboration: Work together in real-time, no matter where your team is located
  • Beyond Formulas: Tackle complex analysis that traditional spreadsheets can't handle

Get started for free.

Watch The Demo 📊✨

Top comments (0)

Image of Checkly

Incident Management 101: What Devs Need to Know in 2025

  • Detect issues before your users do
  • Use synthetic checks for proactive coverage
  • Automate root cause workflows
  • Communicate incidents clearly to your team
  • Learn how to triage, escalate, and resolve faster

Watch session

👋 Kindness is contagious

Explore a trove of insights in this engaging article, celebrated within our welcoming DEV Community. Developers from every background are invited to join and enhance our shared wisdom.

A genuine "thank you" can truly uplift someone’s day. Feel free to express your gratitude in the comments below!

On DEV, our collective exchange of knowledge lightens the road ahead and strengthens our community bonds. Found something valuable here? A small thank you to the author can make a big difference.

Okay