Implement the bitonic sort in src/sn_network.c.
[sort-networks.git] / src / sn_network.h
index 8e6d492..eb5b2e9 100644 (file)
@@ -8,18 +8,19 @@
  * libsortnetwork - src/sn_network.h
  * Copyright (C) 2008-2010  Florian octo Forster
  *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; only version 2 of the License is applicable.
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or (at
+ * your option) any later version.
  *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
+ * This library is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
  *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  *
  * Authors:
  *   Florian octo Forster <ff at octo.it>
@@ -86,6 +87,15 @@ void sn_network_destroy (sn_network_t *n);
 sn_network_t *sn_network_create_odd_even_mergesort (int inputs_num);
 
 /**
+ * Creates a new sort network using Batcher's Bitonic-Mergesort algorithm.
+ *
+ * \param inputs_num Number of inputs / outputs of the sorting network.
+ * \return A pointer to the newly allocated sorting network or \c NULL if an
+ *   invalid number of inputs was given or allocation failed.
+ */
+sn_network_t *sn_network_create_bitonic_mergesort (int inputs_num);
+
+/**
  * Creates a new sorting network using the Pairwise sorting algorithm published
  * by Ian Parberry.
  * \param inputs_num Number of inputs / outputs of the sorting network.
@@ -95,6 +105,18 @@ sn_network_t *sn_network_create_odd_even_mergesort (int inputs_num);
 sn_network_t *sn_network_create_pairwise (int inputs_num);
 
 /**
+ * Append another network to a given network.
+ *
+ * \param n The comparator network to which the other network is added. This
+ *   network is modified.
+ * \param other The network to be added to the first network. This network is
+ *   consumed by this function and the memory pointed to is freed. You cannot
+ *   use that network after this call, so use sn_network_clone() if required.
+ * \return Zero on success, non-zero on failure.
+ */
+int sn_network_network_add (sn_network_t *n, sn_network_t *other);
+
+/**
  * Append a new stage to a comparator network.
  *
  * \param n The comparator network to which to add the stage.