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

Revision 39b13612ebd645a65eda854771b517371f2f858a authored by ennetws on 13 March 2015, 18:17:18 UTC, committed by ennetws on 13 March 2015, 18:17:18 UTC
Create README.md
1 parent c702819
  • Files
  • Changes
  • adfc2e5
  • /
  • DynamicVoxel
  • /
  • DoubleTupleMap.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.

  • revision
  • directory
  • content
revision badge
swh:1:rev:39b13612ebd645a65eda854771b517371f2f858a
directory badge
swh:1:dir:edd3ff344c75f506a69780cf3c38ee37c8e7341f
content badge
swh:1:cnt:420eb3c2b7875e821de15f1a3b31bdbd108c162f

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.

  • revision
  • directory
  • content
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
DoubleTupleMap.h
#include <QHash>

#ifndef WIN32
#include <tr1/functional>
#endif

struct DoubleTuple{
    double x, y, z;
    int index;

    DoubleTuple(double X = 0, double Y = 0, double Z = 0, int Index = -1){
        x = X; y = Y; z = Z; index = Index;
    }

    bool operator== (const DoubleTuple & other) const{
        return this->x == other.x && this->y == other.y && this->z == other.z;
    }
};

template <class T>
inline void hash_combine(std::size_t& seed, const T& v)
{
    std::tr1::hash<T> hasher;
    seed ^= hasher(v) + 0x9e3779b9 + (seed<<6) + (seed>>2);
}

struct DoubleTupleMap{

    void insert(double x, double y, double z, int index = -1)
    {
        size_t key = hash(x,y,z);

        map[ key ].push_back( DoubleTuple(x,y,z, index) );
    }

    int count(double x, double y, double z)
    {
        size_t key = hash(x,y,z);
        if(!map.contains( key )) return 0;

        return map[ key ].count( DoubleTuple(x,y,z, -1) );
    }

    int firstIndex(double x, double y, double z)
    {
        QList<DoubleTuple> l = map[ hash(x,y,z) ];

        return l.takeAt( l.indexOf(DoubleTuple(x,y,z,-1)) ).index;
    }

    inline size_t hash(double x, double y, double z){
        size_t seed = 0;

        hash_combine(seed, x);
        hash_combine(seed, y);
        hash_combine(seed, z);

        return seed;
    }

    QHash< size_t, QList<DoubleTuple> > map;
};
The diff you're trying to view is too large. Only the first 1000 changed files have been loaded.
Showing with 0 additions and 0 deletions (0 / 0 diffs computed)
swh spinner

Computing file changes ...

back to top

Software Heritage — Copyright (C) 2015–2026, 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