return (n);
} /* }}} sn_network_t *sn_network_unserialize */
+int sn_network_compare (const sn_network_t *n0, const sn_network_t *n1) /* {{{ */
+{
+ int status;
+ int i;
+
+ if (n0 == n1)
+ return (0);
+ else if (n0 == NULL)
+ return (-1);
+ else if (n1 == NULL)
+ return (1);
+
+ if (n0->inputs_num < n1->inputs_num)
+ return (-1);
+ else if (n0->inputs_num > n1->inputs_num)
+ return (1);
+
+ if (n0->stages_num < n1->stages_num)
+ return (-1);
+ else if (n0->stages_num > n1->stages_num)
+ return (1);
+
+ for (i = 0; i < n0->stages_num; i++)
+ {
+ status = sn_stage_compare (n0->stages[i], n1->stages[i]);
+ if (status != 0)
+ return (status);
+ }
+
+ return (0);
+} /* }}} int sn_network_compare */
+
uint64_t sn_network_get_hashval (const sn_network_t *n) /* {{{ */
{
uint64_t hash;
*/
sn_network_t *sn_network_unserialize (char *buffer, size_t buffer_size);
+/**
+ * Compares two networks and returns zero if they are equal. If they are not
+ * equal, a number greater than zero or less than zero is returned in a
+ * consistent matter, so this function can be used to sort networks and detect
+ * duplicates. It is strongly recommended that you call sn_network_unify()
+ * before comparing two networks, because they internal structure does matter
+ * for this function.
+ *
+ * \return Zero if the two networks are equal, non-zero otherwise. Return
+ * values are consistent so this function can be used to sort networks.
+ * \see sn_network_unify
+ */
+int sn_network_compare (const sn_network_t *n0, const sn_network_t *n1);
+
uint64_t sn_network_get_hashval (const sn_network_t *n);
#endif /* SN_NETWORK_H */
return (s);
} /* sn_stage_t *sn_stage_unserialize */
+int sn_stage_compare (const sn_stage_t *s0, const sn_stage_t *s1) /* {{{ */
+{
+ int status;
+ int i;
+
+ if (s0 == s1)
+ return (0);
+ else if (s0 == NULL)
+ return (-1);
+ else if (s1 == NULL)
+ return (1);
+
+ if (s0->comparators_num < s1->comparators_num)
+ return (-1);
+ else if (s0->comparators_num > s1->comparators_num)
+ return (1);
+
+ for (i = 0; i < s0->comparators_num; i++)
+ {
+ status = sn_comparator_compare (s0->comparators + i, s1->comparators + i);
+ if (status != 0)
+ return (status);
+ }
+
+ return (0);
+} /* }}} int sn_stage_compare */
+
uint64_t sn_stage_get_hashval (const sn_stage_t *s) /* {{{ */
{
uint64_t hash;
*/
sn_stage_t *sn_stage_unserialize (char **buffer, size_t *buffer_size);
+int sn_stage_compare (const sn_stage_t *s0, const sn_stage_t *s1);
+
uint64_t sn_stage_get_hashval (const sn_stage_t *s);
#endif /* SN_STAGE_H */