Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Postgres/src/include/lib/   (Postgres Database Version 18.4©)  Datei vom 11.4.2026 mit Größe 1 kB image not shown  

Quelle  qunique.h

  Sprache: C
 

/*-------------------------------------------------------------------------
 *
 * qunique.h
 *  inline array unique functions
 * Portions Copyright (c) 2019-2025, PostgreSQL Global Development Group
 *
 * IDENTIFICATION
 *  src/include/lib/qunique.h
 *-------------------------------------------------------------------------
 */


#ifndef QUNIQUE_H
#define QUNIQUE_H

/*
 * Remove duplicates from a pre-sorted array, according to a user-supplied
 * comparator.  Usually the array should have been sorted with qsort() using
 * the same arguments.  Return the new size.
 */

static inline size_t
qunique(void *array, size_t elements, size_t width,
  int (*compare) (const void *, const void *))
{
 char    *bytes = (char *) array;
 size_t  i,
    j;

 if (elements <= 1)
  return elements;

 for (i = 1, j = 0; i < elements; ++i)
 {
  if (compare(bytes + i * width, bytes + j * width) != 0 &&
   ++j != i)
   memcpy(bytes + j * width, bytes + i * width, width);
 }

 return j + 1;
}

/*
 * Like qunique(), but takes a comparator with an extra user data argument
 * which is passed through, for compatibility with qsort_arg().
 */

static inline size_t
qunique_arg(void *array, size_t elements, size_t width,
   int (*compare) (const void *, const void *, void *),
   void *arg)
{
 char    *bytes = (char *) array;
 size_t  i,
    j;

 if (elements <= 1)
  return elements;

 for (i = 1, j = 0; i < elements; ++i)
 {
  if (compare(bytes + i * width, bytes + j * width, arg) != 0 &&
   ++j != i)
   memcpy(bytes + j * width, bytes + i * width, width);
 }

 return j + 1;
}

#endif       /* QUNIQUE_H */

Messung V0.5 in Prozent
C=95 H=88 G=91

¤ Dauer der Verarbeitung: 0.16 Sekunden  (vorverarbeitet am  2026-08-06) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.