src/sn_network.[ch]: Implement sn_network_network_add().
[sort-networks.git] / src / sn_network.h
index d312c35..716c2a3 100644 (file)
@@ -26,7 +26,6 @@
  * \endverbatim
  **/
 
-
 #ifndef SN_NETWORK_H
 #define SN_NETWORK_H 1
 
@@ -87,6 +86,27 @@ void sn_network_destroy (sn_network_t *n);
 sn_network_t *sn_network_create_odd_even_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.
+ * \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_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.
@@ -202,6 +222,16 @@ int sn_network_compress (sn_network_t *n);
 int sn_network_normalize (sn_network_t *n);
 
 /**
+ * Removes an input and all comparators touching that input from the comparator
+ * network.
+ *
+ * \param n The network to modify.
+ * \param input The zero-based index of the input to remove.
+ * \return Zero on success, non-zero on failure.
+ */
+int sn_network_remove_input (sn_network_t *n, int input);
+
+/**
  * Removes an inputs from a comparator network by assuming positive or negative
  * infinity to be supplied to a given input. The value will take a
  * deterministic way through the comparator network. After removing the path
@@ -217,6 +247,9 @@ int sn_network_normalize (sn_network_t *n);
  */
 int sn_network_cut_at (sn_network_t *n, int input, enum sn_network_cut_dir_e dir);
 
+/* FIXME: Documentation */
+int sn_network_cut (sn_network_t *n, int *mask);
+
 /**
  * An alias for sn_network_combine_odd_even_merge().
  */