Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

  • adfc2e5
  • /
  • segment
  • /
  • MyPriorityQueue.h
Raw File Download

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
  • directory
content badge Iframe embedding
swh:1:cnt:d22e5ca100293e307f350d20c22cc7b1f658268a
directory badge Iframe embedding
swh:1:dir:1d6653f9f764314e8029f2afc6f043463d3f9d49

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • content
  • directory
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
MyPriorityQueue.h
#pragma once
#include <set>
#include "CurveskelHelper.h"

namespace CurveskelTypes{

	class MyPriorityQueue
	{
	public:
		class EdgeCompareFunctor{
		public:
			CurveskelTypes::ScalarEdgeProperty elengths;

			EdgeCompareFunctor(CurveskelModel* skel){
				elengths = skel->edge_property<CurveskelTypes::Scalar>("e:length");
			}

			bool operator() (const CurveskelTypes::Edge& lhs, const CurveskelTypes::Edge& rhs) const{
				CurveskelTypes::Scalar p0 = elengths[lhs];
				CurveskelTypes::Scalar p1 = elengths[rhs];
				return (p0 == p1) ? (lhs.idx()<rhs.idx()) : (p0 < p1);
			}
		};   
		EdgeCompareFunctor compareFunctor;
		std::set<CurveskelTypes::Edge, EdgeCompareFunctor> set;

		MyPriorityQueue(CurveskelModel* skel) : compareFunctor(skel), set(compareFunctor){}

		void insert(CurveskelTypes::Edge edge, CurveskelTypes::Scalar length){
			compareFunctor.elengths[edge] = length;
			set.insert(edge);
		}

		CurveskelTypes::Edge pop(){
			CurveskelTypes::Edge e = *(set.begin());
			set.erase(e);
			compareFunctor.elengths[e] = -1.0;
			return e;
		}

		bool update(CurveskelTypes::Edge edge, CurveskelTypes::Scalar /*length*/){
			// erase the edge
			int nerased = set.erase(edge);

			if( nerased != 1 ){
				qDebug() << "I was supposed to erase one element, but I erased: " << nerased; 
				return false;  
			}

			// re-insert it
			set.insert(edge);

			return true;
		}

		bool empty(){ return set.empty(); }

		bool has(CurveskelTypes::Edge edge){ return set.find(edge) != set.end(); }
	};

}

back to top

Software Heritage — Copyright (C) 2015–2025, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API