Branch: Tag:

2001-12-10

2001-12-10 02:08:17 by Martin Stjernholm <mast@lysator.liu.se>

Multiset implementation using rbtree. --with-new-multisets required to
enable it. There's still no glue to use most of the new features, except
that the iterator (and foreach) works without locking the multiset index,
and that multiset data blocks use copy-on-write (just like mappings).

Rev: src/acconfig.h:1.94
Rev: src/builtin.cmod:1.71
Rev: src/builtin_functions.c:1.416
Rev: src/configure.in:1.562
Rev: src/docode.c:1.137
Rev: src/encode.c:1.133
Rev: src/gc.c:1.178
Rev: src/interpret.c:1.253
Rev: src/iterators.cmod:1.15
Rev: src/main.c:1.138
Rev: src/multiset.c:1.40
Rev: src/multiset.h:1.20
Rev: src/opcodes.c:1.117
Rev: src/operators.c:1.143
Rev: src/pike_types.c:1.183

6:   /**/   #include "global.h"   #include <math.h> - RCSID("$Id: operators.c,v 1.142 2001/10/28 18:02:27 nilsson Exp $"); + RCSID("$Id: operators.c,v 1.143 2001/12/10 02:08:16 mast Exp $");   #include "interpret.h"   #include "svalue.h"   #include "multiset.h"
934:    {    struct mapping *m;    + #ifdef PIKE_NEW_MULTISETS +  int got_cmp_less = !!multiset_get_cmp_less (sp[-1].u.multiset); +  struct array *ind = multiset_indices (sp[-1].u.multiset); +  pop_stack(); +  push_array (ind); +  if (got_cmp_less) +  m=merge_mapping_array_unordered(sp[-2].u.mapping, +  sp[-1].u.array, +  PIKE_ARRAY_OP_SUB); +  else    m=merge_mapping_array_ordered(sp[-2].u.mapping, -  +  sp[-1].u.array, +  PIKE_ARRAY_OP_SUB); + #else +  m=merge_mapping_array_ordered(sp[-2].u.mapping,    sp[-1].u.multiset->ind,    PIKE_ARRAY_OP_SUB); -  + #endif +     pop_n_elems(2);    push_mapping(m);    return;
1180:    {    struct mapping *m;    + #ifdef PIKE_NEW_MULTISETS +  int got_cmp_less = !!multiset_get_cmp_less (sp[-1].u.multiset); +  struct array *ind = multiset_indices (sp[-1].u.multiset); +  pop_stack(); +  push_array (ind); +  if (got_cmp_less) +  m=merge_mapping_array_unordered(sp[-2].u.mapping, +  sp[-1].u.array, +  PIKE_ARRAY_OP_AND); +  else    m=merge_mapping_array_ordered(sp[-2].u.mapping, -  +  sp[-1].u.array, +  PIKE_ARRAY_OP_AND); + #else +  m=merge_mapping_array_ordered(sp[-2].u.mapping,    sp[-1].u.multiset->ind,    PIKE_ARRAY_OP_AND); -  + #endif +     pop_n_elems(2);    push_mapping(m);    return;