![]() |
librnr
1.14.5
RoadNarrows Robotics Common Library 1
|
Example of a librnr simple associative map operations. More...
#include <stdio.h>#include <string.h>#include "rnr/rnrconfig.h"#include "rnr/new.h"#include "rnr/assoc.h"Go to the source code of this file.
Classes | |
| struct | Factoids_T |
| Some solar body facts. More... | |
Macros | |
| #define | AMAP_NAME Planet |
| associate map namespace | |
| #define | AMAP_XTYPE BodyId_T |
| x data type | |
| #define | AMAP_YTYPE Factoids_T* |
| make the magic More... | |
Enumerations | |
| enum | BodyId_T { unknown, Sun, Mercury, Venus, Earth, Moon, Mars, Phobos, Deimos, Ceres, Jupiter, Io, Europa, Ganymede, Callisto, Saturn, Titan, Uranus, Titania, Neptune, Triton, Pluto, Charon, Eris, NumBodies, unknown, Sun, Mercury, Venus, Earth, Moon, Mars, Phobos, Deimos, Ceres, Jupiter, Io, Europa, Ganymede, Callisto, Saturn, Titan, Uranus, Titania, Neptune, Triton, Pluto, Charon, Eris, NumBodies } |
| Major and minor solar body ids (partial, of course). | |
Functions | |
| static void | AddNewBody (BodyId_T eThisBodyId, double diam, char *units_diam, double dist, char *units_dist, double period, char *units_period, BodyId_T eOrbitsId) |
| Add a new body to our db, normalizing units. More... | |
| void | PrintBody (Factoids_T *pOid) |
| Print solar body facts. More... | |
| int | CmpIds (const BodyId_T x1, const BodyId_T x2) |
| X comparator callback. More... | |
| int | CmpOids (const Factoids_T *y1, const Factoids_T *y2) |
| Y comparator callback. More... | |
| int | main (int argc, char *argv[]) |
| Example main. More... | |
Variables | |
| Nvp_T | SolarBodyNames [] |
| Solar body name-id pairs (partial). More... | |
| AssocMapPlanetPoint_T | SolarBodyFacts [NumBodies] |
| the solar body factoids | |
| size_t | BodyCount = 0 |
| number of bodies in facts table above. | |
Example of a librnr simple associative map operations.
Definition in file example_assoc.c.
| #define AMAP_YTYPE Factoids_T* |
|
static |
Add a new body to our db, normalizing units.
| eThisBodyId | Solar body id. |
| diam | Body diameter. |
| units_diam | Diameter units. |
| dist | Average orbital distance from the Sun. |
| units_dist | Distance units. |
| period | Average orbital period about parent body. |
| units_period | Period units. |
| eOrbitsId | Parent body. |
Definition at line 140 of file example_assoc.c.
References arraysize, BodyCount, Factoids_T::m_eOrbits, Factoids_T::m_fDiam, Factoids_T::m_fOrbitalAvgDist, Factoids_T::m_fOribtalPeriod, Factoids_T::m_sName, NEW, NULL, NvpVal2Name(), and SolarBodyFacts.
Referenced by main().
X comparator callback.
| x1 | Solar body id x1. |
| x2 | Solar body id x2. |
Definition at line 216 of file example_assoc.c.
Referenced by main().
| int CmpOids | ( | const Factoids_T * | y1, |
| const Factoids_T * | y2 | ||
| ) |
Y comparator callback.
| y1 | Solar body factoids y1. |
| y2 | Solar body factoids y2. |
Definition at line 230 of file example_assoc.c.
References Factoids_T::m_sName.
Referenced by main().
| int main | ( | int | argc, |
| char * | argv[] | ||
| ) |
Example main.
| argc | Command-line argument count. |
| argv | Command-line argument list. |
Definition at line 244 of file example_assoc.c.
References AddNewBody(), BodyCount, CmpIds(), CmpOids(), Factoids_T::m_sName, NULL, PrintBody(), and SolarBodyFacts.
Referenced by shm_mutex_unlock().
| void PrintBody | ( | Factoids_T * | pOid | ) |
Print solar body facts.
| pOid | Pointer to facts. |
Definition at line 196 of file example_assoc.c.
References arraysize, Factoids_T::m_eOrbits, Factoids_T::m_fDiam, Factoids_T::m_fOrbitalAvgDist, Factoids_T::m_fOribtalPeriod, Factoids_T::m_sName, and NvpVal2Name().
Referenced by main().
| Nvp_T SolarBodyNames[] |
Solar body name-id pairs (partial).
Definition at line 98 of file example_assoc.c.