Alien-Judy

 view release on metacpan or  search on metacpan

src/judy-1.0.5/examples/Judy1Op.c  view on Meta::CPAN


/*
 * @(#) $Revision: 4.2 $ $Source: /judy/src/funcs/Judy1Op.c $
 *
 * Judy1 set operations.
 *
 * The name of this function, "Judy1Op", was carefully chosen from
 * a list of alternatives:
 *
 *   Judy1Op()  - It's hard to see that O is a letter and not a zero.
 *   Judy1Set() - Sounds like you are setting a bit.
 *   Judy1BS()  - BS for Bit Set functions.
 *   Judy1SO()  - SO for Set Operations
 *   Judy1AndIDontGiveADarn() - too long but goes with
 *   Judy1WhoseOnFirst() - now called Judy1First() and
 *   Judy1WhatsOnSecond() - now called Judy1Next()
 *
 * But Judy1SetOp() would conflict with Judy1Set() if we rename Judy1Set(), so
 * Judy1Op() it is.
 */

#include "Judy.h"
#include "Judy1Op.h"

/*******************************************************************
 * Name: Judy1Op
 *
 * Description:
 *       Logical set operations on Judy1 arrays.
 *
 *       All of these operations can be done on an unbounded array because
 *       the dreaded "NOT" is avoided.  The "NOT"'s can be implemented
 *       when Judy1 supports them.
 *
 * Parameters:
 *       PPvoid_t PPDest (OUT)
 *            Ptr to the Judy destination array.
 *            Any initial value pointed to by PPDest is ignored.
 *
 *       Pvoid_t PSet1 (IN)
 *            First Judy1 set.
 *            This will be NULL for an empty Judy1 array.
 *
 *       Pvoid_t PSet2 (IN)
 *            Second Judy1 set.
 *            This will be NULL for an empty Judy1 array.
 *
 *       Word_t Operation (IN)
 *            Operation to be performed (ie. PSet1 {Operation} PSet2)
 *            Valid Operation values are:
 *
 *            JUDY1OP_AND     - intersection of two sets
 *            JUDY1OP_OR      - union of two sets
 *            JUDY1OP_ANDNOT  - set1 with set2 removed
 *
 *       JError_t * PJError (OUT)
 *            Judy Error struct used to return Judy error.
 *
 * Returns:
 *      !JERR if successful
 *       JERR if an error occurs
 *       If the error is a caller error (invalid Operation or no PPDest)
 *       then the PJError error code will be JU_ERRNO_NONE.
 */
int
Judy1Op(PPvoid_t PPDest, Pvoid_t PSet1, Pvoid_t PSet2,
        Word_t Operation, JError_t * PJError)
{
    Pvoid_t   PnewJArray = 0;           // empty Judy array
    Word_t    Index1 = 0L;
    Word_t    Index2 = 0L;
    int       Judy_rv;

    if (!PPDest)
        return JERR;

    switch (Operation)
    {



( run in 1.590 second using v1.01-cache-2.11-cpan-39bf76dae61 )