home *** CD-ROM | disk | FTP | other *** search
- /* --------------------------------------------------------------------------
- * Copyright 1992 by Forschungszentrum Informatik (FZI)
- *
- * You can use and distribute this software under the terms of the licence
- * you should have received along with this program.
- * If not or if you want additional information, write to
- * Forschungszentrum Informatik, "STONE", Haid-und-Neu-Strasse 10-14,
- * D-7500 Karlsruhe 1, Germany.
- * --------------------------------------------------------------------------
- */
- // **************************************************************************
- // Module Bag 03/07/89 Bernhard Schiefer (bs)
- // modified: 9/8/90 (ja)
- // 24/10/91 (bs)
- // **************************************************************************
- // implements methods of classes: Bag
- // **************************************************************************
-
- #include "agg_err.h"
- #include "trc_agg.h"
- #include "sys.h"
-
- #include "agg_sos.h"
-
- /*
- Ein Bag ist eine Erweiterung von Set, eingetragene Objekte koennen auch in
- mehrfachen Exemplaren eingetragen werden.
- Die Implementierung setzt auf einem Mapping auf, und zwar wird eine Abbildung
- von einem Objekt auf eine Zahl benutzt. Die Zahl gibt die Anzahl an, wieviel
- Exemplare dieses Objekts im Bag sind. Die Moeglichkeit im Schema ein
- Object_sos_Int_Mapping zu benutzen wurde verworfen, stattdessen wird das
- ordinaere Mapping benutzt, wobei ein Entity als Zahl sos_Interpretiert wird.
- Der Container liegt nutzlos auf der Platte.
- */
-
- // **************************************************************************
- void sos_Object_Bag::search_succ_pred (sos_Bag_node bn, Index steps,
- sos_Object& o, sos_Int& no, sos_Int& max)
- // **************************************************************************
- // suche ausgehend von dem Element in bag_node steps Schritte nach vorne
- // bzw. hsos_Inten. Liefere in o,no,max die neue Position. Ist die
- // Position nicht gueltig, so ist o = my_no_object
- {
- sos_Object_sos_Int_Mapping m = self.get_m();
- sos_Cursor cur = m.open_cursor();
-
- max = bn.get_tag_max();
- no = bn.get_tag_no();
- o = bn.get_key_val();
- sos_Object my_no_object = m;
-
- m.move_cursor (cur, o);
-
- for (;o != my_no_object AND steps != 0; )
- { if (steps > 0)
- { // Muss ich aufs naechste Element gehen ?
- if (no+steps > max)
- { // Ja
- if (m.to_succ (cur))
- { o = m.get_key (cur);
- steps -= (max-no+1);
- no = 1;
- max = m.get_info (cur);
- }
- else
- o = my_no_object;
- }
- else
- { // Nein
- no += steps;
- steps = 0;
- }
- }
- else
- { // muss ich aufs fruehere Element gehen ?
- if (steps+no < 1)
- { // Ja
- if (m.to_pred (cur))
- { o = m.get_key (cur);
- steps += no;
- max = m.get_info (cur);
- no = max;
- }
- else
- o = my_no_object;
- // Im Augenblick steht der Zeiger auf der letzten
- // Auspraegung des Objects
- }
- else
- { // Nein
- no += steps;
- steps = 0;
- }
- }
- } // for
- } // sos_Object_Bag::search_succ_pred
-
-
- // **************************************************************************
- void sos_Object_Bag::write_current (sos_Cursor c,
- sos_Object o,
- sos_Int no,
- sos_Int max)
- // **************************************************************************
- // schreibe in den Cursor die Position auf dem sos_Object o,
- // der Exemplarnummer no und der Exemplaranzahl max.
- {
- sos_Bag_node bn = sos_Bag_node::make (c.get_current());
- sos_Object_sos_Int_Mapping m = self.get_m();
-
- bn.set_key_val (o);
- bn.set_tag_no (no);
- bn.set_tag_max (max);
- } // sos_Object_Bag::write_current
-
- // **************************************************************************
- sos_Int sos_Object_Bag::get_no_of_elements (sos_Object_sos_Int_Mapping m,
- sos_Object o)
- // **************************************************************************
- // liefert die Anzahl der Vorkommen, die im Mapping m vom Objekt o sind
- {
- if (m.is_key (o))
- return m[o];
- else
- return 0;
- } // ** sos_Object_Bag::get_no_of_element
-
- // **************************************************************************
- sos_Int sos_Object_Bag::set_no_of_elements (sos_Object_sos_Int_Mapping m,
- sos_Object o,
- sos_Int old_no,
- sos_Int new_no)
- // **************************************************************************
- // Setzt die Anzahl der Vorkommen von o von vormals old_no auf new_no
- // Es wird die Anzahl zurueckgeliefert, die dazukam
- {
- if ((new_no == 0) AND (old_no >0))
- {
- m.remove (o);
- return -old_no;
- }
- else
- // Hier ist new_no>0 oder old_no==0
- if ((new_no > 0) AND (old_no != new_no))
- {
- m.insert (o, new_no);
- return new_no - old_no;
- }
- else
- // Hier ist old_no==new_no => nichts
- return 0;
- } // ** sos_Object_Bag::set_no_of_elements
-
-
- // **************************************************************************
- void sos_Object_Bag::local_initialize (sos_Object_Bag bag)
- // **************************************************************************
- { T_PROC ("sos_Object_Bag::local_initialize");
- TT (agg_H, T_ENTER);
-
- bag.set_cardinality (0);
- bag.set_m (sos_Object_sos_Int_Mapping::create
- (bag.container(),
- bag.get_list_cursor(),
- bag.get_based_on_equal()));
-
- TT (agg_H, T_LEAVE);
- } // ** local_initialize **
-
- // **************************************************************************
- void sos_Object_Bag::local_finalize (sos_Object_Bag bag)
- // **************************************************************************
- { T_PROC ("sos_Object_Bag::local_finalize");
- TT (agg_H, T_ENTER);
-
- bag.get_m().destroy();
-
- TT (agg_H, T_LEAVE);
- } // ** local_finalize **
-
- // **************************************************************************
- sos_Int sos_Object_Bag::entity_occurs (sos_Cursor c)
- // **************************************************************************
- { T_PROC ("sos_Object_Bag::entity_occurs");
- TT (agg_H, T_ENTER);
-
- sos_Int no_of_entries = self.get_m().get_info (c);
-
- TT (agg_H, T_LEAVE);
- return no_of_entries;
- } // ** sos_Object_Bag::entity_occurs (sos_Cursor)
-
- // **************************************************************************
- sos_Bool sos_Object_Bag::to_diff_succ (sos_Cursor c, Index steps)
- // **************************************************************************
- { T_PROC ("sos_Object_Bag::to_diff_succ");
- TT (agg_H, T_ENTER);
-
- sos_Object_sos_Int_Mapping m = self.get_m();
- err_assert (c.defined_for (m), "sos_Object_Bag:to_diff_succ");
- err_assert (self.is_valid (c),"sos_Object_Bag:to_diff_succ");
-
- sos_Bag_node bn = sos_Bag_node::make (c.get_current());
- sos_Bool valid = m.to_succ (c, steps);
- if (valid)
- { bn.set_tag_no(1);
- bn.set_tag_max (m.get_info (c));
- }
-
- TT (agg_H, T_LEAVE);
- return valid;
- } // ** sos_Object_Bag::to_diff_succ **
-
- // **************************************************************************
- sos_Bool sos_Object_Bag::to_diff_pred (sos_Cursor c, Index steps)
- // **************************************************************************
- { T_PROC ("sos_Object_Bag::to_diff_pred");
- TT (agg_H, T_ENTER);
-
- sos_Object_sos_Int_Mapping m = self.get_m();
- err_assert (c.defined_for (m), "sos_Object_Bag:to_diff_pred");
- err_assert (self.is_valid (c),"sos_Object_Bag:to_diff_pred");
-
- sos_Bag_node bn = sos_Bag_node::make (c.get_current());
- sos_Bool valid = m.to_pred (c, steps);
- if (valid)
- { sos_Int max = m.get_info (c);
- bn.set_tag_no (max);
- bn.set_tag_max (m.get_info (c));
- }
-
- TT (agg_H, T_LEAVE);
- return valid;
- } // ** sos_Object_Bag::to_diff_pred **
-
- // **************************************************************************
- void sos_Object_Bag::eliminate (sos_Object o)
- // **************************************************************************
- // loescht alle Vorkommen von o
- {
- T_PROC ("sos_Object_Bag::eliminate");
- TT (agg_H, T_ENTER);
-
- sos_Object_sos_Int_Mapping m = self.get_m();
- sos_Int no_of_entries = 0;
-
- if (m.is_key (o))
- { no_of_entries = m[o];
- m.remove (o);
- self.set_cardinality (self.get_cardinality() - no_of_entries);
- }
-
- TT (agg_H, T_LEAVE);
- } // ** sos_Object_Bag::eliminate **
-
- // **************************************************************************
- sos_Int sos_Object_Bag::occurrences (sos_Object o)
- // **************************************************************************
- {
- T_PROC ("sos_Object_Bag::occurrences");
- TT (agg_H, T_ENTER);
-
- sos_Object_sos_Int_Mapping m = self.get_m();
- sos_Int no_of_entries = 0;
-
- if (m.is_key (o))
- no_of_entries = m[o];
-
- TT (agg_H, T_LEAVE);
- return no_of_entries;
- } // ** sos_Object_Bag::occurrences (sos_Object)
-
- // **************************************************************************
- sos_Int sos_Object_Bag::insert (sos_Object o)
- // **************************************************************************
- // fuege das Objekt o in das Bag ein, es wird die Anzahl der danach (!) im
- // Bag vorhandenen Exemplare geliefert.
- {
- T_PROC ("sos_Object_Bag::insert");
- TT (agg_H, T_ENTER);
-
- sos_Object_sos_Int_Mapping m = self.get_m();
- sos_Int no_of_entries = 1;
-
- // hole die Abbildung von o, um herauszufinden, wieviel Objekte o
- // schon vorhanden sind
-
- // Der Offset wird sos_Interpretiert als die Anzahl der Objekte o, die schon
- // vorhanden sind.
- if (m.is_key (o))
- no_of_entries = m[o]+1;
-
- m.insert (o, no_of_entries); // ueberschreibe altes o
-
- self.set_cardinality (self.get_cardinality()+1);
- TT (agg_H, T_LEAVE);
- return no_of_entries;
- } // ** sos_Object_Bag::insert **
-
- // **************************************************************************
- sos_Int sos_Object_Bag::remove (sos_Object o)
- // **************************************************************************
- // loesche ein Objekt o, es wird die Anzahl der Objekte, die
- // vorher (!) im bag waren, zurueckgeliefert
- {
- T_PROC ("sos_Object_Bag::remove");
- TT (agg_H, T_ENTER);
-
- sos_Object_sos_Int_Mapping m = self.get_m();
- sos_Int no_of_entries = 0;
-
- if (m.is_key (o))
- { no_of_entries = m[o];
- if (no_of_entries == 1)
- m.remove (o);
- else
- m.insert (o, no_of_entries-1);
-
- self.set_cardinality (self.get_cardinality() - 1);
- }
-
- TT (agg_H, T_LEAVE);
- return no_of_entries;
- } // ** remove **
-
-
- // **************************************************************************
- void sos_Object_Bag::operator+= (sos_Object_Bag aset)
- // **************************************************************************
- // Nach A += B wurden alle Elemente in B zu A aufaddiert
- {
- T_PROC ("sos_Object_Bag::operator+=");
- TT (agg_H, T_ENTER);
-
- sos_Object_sos_Int_Mapping this_m = self.get_m();
- sos_Object_sos_Int_Mapping aset_m = aset.get_m();
- sos_Cursor cur = aset_m.open_cursor ();
- for (;aset_m.is_valid (cur);)
- {
- sos_Object o = aset_m.get_key (cur);
- if (aset_m.is_valid (cur) == TRUE)
- aset_m.to_succ (cur);
- sos_Int this_entries = self.get_no_of_elements (this_m, o);
- sos_Int aset_entries = self.get_no_of_elements (aset_m, o);
- sos_Int add=self.set_no_of_elements (this_m, o,
- this_entries, this_entries+aset_entries);
- self.set_cardinality (self.get_cardinality()+add);
- } // for
- aset_m.close_cursor (cur);
- TT (agg_H, T_LEAVE);
- } // ** _sos_Object_Bag:;operator+= **
-
- // **************************************************************************
- void sos_Object_Bag::operator-= (sos_Object_Bag aset)
- // **************************************************************************
- // Nach A -= B wurden aus A alle Elemente, die in B sind, entfernt
- { T_PROC ("sos_Object_Bag::operator-=");
- TT (agg_H, T_ENTER);
-
- sos_Object_sos_Int_Mapping this_m = self.get_m();
- sos_Object_sos_Int_Mapping aset_m = aset.get_m();
-
- sos_Cursor cur = aset_m.open_cursor();
-
- for (;(aset_m.is_valid (cur));)
- { sos_Object o = aset_m.get_key (cur);
- if (aset_m.is_valid (cur))
- aset_m.to_succ (cur);
-
- // Wie oft gibt`s das Element ?
- sos_Int this_entries = self.get_no_of_elements (this_m, o);
- sos_Int aset_entries = self.get_no_of_elements (aset_m, o);
- sos_Int new_entries = this_entries-aset_entries;
- if (new_entries < 0)
- new_entries = 0;
-
- sos_Int add = self.set_no_of_elements (this_m, o, this_entries, new_entries);
-
- self.set_cardinality (self.get_cardinality()+add);
- } // for
- aset_m.close_cursor (cur);
- TT (agg_H, T_LEAVE);
- } // ** _sos_Object_Bag:;operator-= **
-
- // **************************************************************************
- void sos_Object_Bag::operator*= (sos_Object_Bag aset)
- // **************************************************************************
- // Liefert die Schnittmenge von A und B,
- // Also entferne aus self alle Elemente, die nicht in aset sind
- {
- T_PROC ("sos_Object_Bag::operator*=");
- TT (agg_H, T_ENTER);
-
-
- sos_Object_sos_Int_Mapping aset_m = aset.get_m();
- sos_Object_sos_Int_Mapping this_m = self.get_m();
- sos_Cursor cur = this_m.open_cursor();
- sos_Bool cur_valid = this_m.is_valid (cur);
- sos_Int length = self.get_cardinality();
- for (;(cur_valid);)
- { sos_Object o = this_m.get_key (cur);
- // erhoehe gleich den Cursor, da das sos_Object in set_no_of_element
- // eventuel geloescht wird. Wuerde dann to_succ aufgerufen,
- // gaebe es den altbekannten SEGV
- if (cur_valid)
- cur_valid = this_m.to_succ (cur);
-
- // Wieviel Auspraegungen von diesem Element gibt es ?
- sos_Int this_entries = self.get_no_of_elements (this_m, o);
- sos_Int aset_entries = self.get_no_of_elements (aset_m, o);
- // Die neue Anzahl ist das Minimum der beiden
- sos_Int new_entries = this_entries;
- if (this_entries > aset_entries )
- new_entries = aset_entries;
-
- sos_Int add = self.set_no_of_elements (this_m, o, this_entries, new_entries);
-
- length += add;
- } // for
- self.set_cardinality (length);
- this_m.close_cursor (cur);
- TT (agg_H, T_LEAVE);
- } // ** sos_Object_Bag::operator*= **
-
- // **************************************************************************
- sos_Bool sos_Object_Bag::operator< (sos_Object_Bag aset)
- // **************************************************************************
- // Liefert TRUE zurueck, wenn jedes Element aus this auch in aset ist
- // und aset mindestens ein Element mehr enthaelt
- {
- T_PROC ("sos_Object_Bag::operator<");
- TT (agg_H, T_ENTER);
-
- sos_Object_sos_Int_Mapping aset_m = aset.get_m();
- sos_Object_sos_Int_Mapping this_m = self.get_m();
-
- // pruefe zuerst, ob die Anzahl der Elemente schon ein Ergebnis liefert
- if (self.get_cardinality() >= aset.get_cardinality())
- {
- TT (agg_H, T_LEAVE);
- return FALSE;
- }
-
- // So, ab hier sind in aset mehr Elemente als in this
-
- sos_Cursor cur = this_m.open_cursor();
- for (;this_m.is_valid (cur);this_m.to_succ (cur))
- { sos_Object o = this_m.get_key (cur);
- sos_Int this_entries = self.get_no_of_elements (this_m, o);
- sos_Int aset_entries = self.get_no_of_elements (aset_m, o);
- if (this_entries > aset_entries)
- {
- this_m.close_cursor (cur);
- TT (agg_H, T_LEAVE);
- return FALSE;
- }
- } // for
- this_m.close_cursor (cur);
-
- // Hier angekommen, ist this < aset
- TT (agg_H, T_LEAVE);
- return TRUE;
- } // ** sos_Object_Bag::operator< **
-
- // **************************************************************************
- sos_Bool sos_Object_Bag::operator<= (sos_Object_Bag aset)
- // **************************************************************************
- // Liefert TRUE zurueck, wenn jedes Element aus this auch in aset ist
- {
- T_PROC ("sos_Object_Bag::operator<=");
- TT (agg_H, T_ENTER);
-
- sos_Object_sos_Int_Mapping aset_m = aset.get_m();
- sos_Object_sos_Int_Mapping this_m = self.get_m();
-
- // pruefe zuerst, ob die Anzahl der Elemente schon ein Ergebnis liefert
- if (self.get_cardinality() > aset.get_cardinality())
- { TT (agg_H, T_LEAVE);
- return FALSE;
- }
-
- // So, ab hier sind in aset mindestens soviele Elemente wie in this
- sos_Cursor cur = this_m.open_cursor();
- for (;this_m.is_valid (cur);this_m.to_succ (cur))
- { sos_Object o = this_m.get_key (cur);
- sos_Int this_entries = self.get_no_of_elements (this_m, o);
- sos_Int aset_entries = self.get_no_of_elements (aset_m, o);
- if (this_entries > aset_entries)
- { this_m.close_cursor (cur);
- TT (agg_H, T_LEAVE);
- return FALSE;
- }
- } // for
- this_m.close_cursor (cur);
- TT (agg_H, T_LEAVE);
- return TRUE;
- } // ** sos_Object_Bag::operator<= **
-
- // **************************************************************************
- sos_Bool sos_Object_Bag::operator> (sos_Object_Bag aset)
- { return sos_Bool (aset < self); }
- // **************************************************************************
-
- // **************************************************************************
- sos_Bool sos_Object_Bag::operator>= (sos_Object_Bag aset)
- { return sos_Bool (aset <= self); }
- // **************************************************************************
-
- // **************************************************************************
- void sos_Object_Bag::max_union (sos_Object_Bag b)
- // **************************************************************************
- { T_PROC ("sos_Object_Bag::max_union");
- TT(agg_H, T_ENTER);
-
- sos_Object_sos_Int_Mapping this_m = self.get_m();
- sos_Object_sos_Int_Mapping b_m = b.get_m();
- sos_Cursor cur = b_m.open_cursor ();
- for (;b_m.is_valid (cur);)
- { sos_Object o;
- o = b_m.get_key (cur);
- b_m.to_succ (cur);
- sos_Int this_entries = self.get_no_of_elements (this_m, o);
- sos_Int b_entries = self.get_no_of_elements (b_m, o);
- if (this_entries < b_entries)
- { sos_Int add = self.set_no_of_elements (this_m, o, this_entries, b_entries);
- self.set_cardinality (self.get_cardinality()+add);
- }
- } // for
- b_m.close_cursor (cur);
- TT (agg_H, T_LEAVE);
- } // ** sos_Object_Bag::max_union **
-
- // **************************************************************************
- void sos_Object_Bag::local_assign (sos_Object_Bag x, sos_Object o)
- // **************************************************************************
- { T_PROC ("sos_Object_Bag::local_assign");
- TT(agg_H, T_ENTER);
-
- sos_Object_Bag y = sos_Object_Bag::make (o);
- x.get_m().assign (y.get_m());
-
- x.set_cardinality (y.get_cardinality());
- TT(agg_H, T_LEAVE);
- } // sos_Object_Bag::local_assign
-
- // **************************************************************************
- sos_Bool sos_Object_Bag::local_equal (sos_Object_Bag x,
- sos_Object o,
- sos_Eq_kind eq_kind)
- // **************************************************************************
- { T_PROC ("sos_Object_Bag::local_equal");
- TT(agg_H, T_ENTER);
-
- sos_Bool result;
-
- if ((eq_kind EQ EQ_STRONG AND NOT o.has_type (x.type())) OR
- (eq_kind EQ EQ_WEAK AND NOT o.isa (x.type())))
- result = FALSE;
- else
- { sos_Object_Bag y = sos_Object_Bag::make (o);
- sos_Object_sos_Int_Mapping x_m = x.get_m();
- sos_Object_sos_Int_Mapping y_m = y.get_m();
- if (x.get_cardinality() != y.get_cardinality())
- result = FALSE;
- else
- { result = TRUE;
- agg_iterate_association (x_m, sos_Object key, sos_Int x_entries)
- { if (x_entries != y.get_no_of_elements (y_m, key))
- { result = FALSE;
- break;
- }
- }
- agg_iterate_association_end (x_m, key, x_entries);
- }
- }
-
- TT(agg_H, T_LEAVE;TB(result));
-
- return result;
- } // sos_Object_Bag::local_equal
-
- // **************************************************************************
- sos_Int sos_Object_Bag::local_hash_value (sos_Object_Bag)
- // **************************************************************************
- { T_PROC ("sos_Object_Bag::local_hash_value");
- TT(agg_H, T_ENTER);
-
- sos_Int result = 0;
-
- TT(agg_H, T_LEAVE);
-
- return result;
- } // sos_Object_Bag::local_hash_value
-
- // **************************************************************************
- sos_Bool sos_Object_Bag::is_element (sos_Object o)
- // **************************************************************************
- { T_PROC ("sos_Object_Bag::is_element");
- TT (agg_H, T_ENTER);
-
- sos_Bool result = self.get_m().is_key (o);
-
- TT (agg_H, T_LEAVE);
- return result;
- } // ** sos_Object_Bag::is_element (sos_Object)
-
- // **************************************************************************
- sos_Object sos_Object_Bag::get (sos_Cursor c)
- // **************************************************************************
- { T_PROC ("sos_Object_Bag::get");
- TT (agg_H, T_ENTER);
-
- err_assert (c.defined_for (self.get_m()), "sos_Object_Bag:get");
- err_assert (self.is_valid (c),"sos_Object_Bag:get");
-
- sos_Object o = sos_Bag_node::make (c.get_current()).get_key_val();
-
- TT (agg_H, T_LEAVE);
- return o;
- } // ** sos_Object_Bag::get **
-
- // **************************************************************************
- void sos_Object_Bag::remove_at (sos_Cursor c)
- // **************************************************************************
- { T_PROC ("sos_Object_Bag::remove_at");
- TT(agg_H, T_ENTER);
-
- err_assert (c.defined_for (self.get_m()), "sos_Object_Bag:remove_at");
- err_assert (self.is_valid (c),"sos_Object_Bag:remove_at");
-
- sos_Object entity = self.get (c);
- if (self.get_list_cursor())
- self.to_succ (c,1);
- else
- { sos_Bag_node bn = sos_Bag_node::make (c.get_current());
- sos_Object my_no_object = self.get_m();
- bn.set_key_val (my_no_object);
- }
- self.remove (entity);
-
- TT(agg_H, T_LEAVE);
- } // sos_Object_Bag::remove_at
-
- // **************************************************************************
- sos_Int sos_Object_Bag::card ()
- // **************************************************************************
- {
- T_PROC ("sos_Object_Bag::card");
- TT (agg_H, T_ENTER);
-
- sos_Int crd = self.get_cardinality();
-
- TT (agg_H, T_LEAVE; TI(crd));
- return crd;
- } // ** card **
-
- // **************************************************************************
- void sos_Object_Bag::clear()
- // **************************************************************************
- { T_PROC ("sos_Object_Bag::clear");
- TT (agg_H, T_ENTER);
-
- self.get_m().clear();
- self.set_cardinality(0);
-
- TT (agg_H, T_LEAVE);
- } // ** clear
-
- // **************************************************************************
- sos_Cursor sos_Object_Bag::open_cursor (sos_Container Cursor_ct)
- // **************************************************************************
- { sos_Container ct = self.container();
- sos_Object_sos_Int_Mapping m = self.get_m();
- sos_Cursor c = sos_Cursor::create(Cursor_ct, m);
- sos_Bag_node bn = sos_Bag_node::create(Cursor_ct);
-
- c.set_current (bn);
- m.to_first (c);
- if (self.is_valid (c))
- { bn.set_tag_no(1);
- bn.set_tag_max (m.get_info (c));
- }
-
- return c;
- } // sos_Object_Bag::open_cursor
-
- // **************************************************************************
- void sos_Object_Bag::close_cursor (sos_Cursor c)
- // **************************************************************************
- {
- c.get_current().destroy();
- c.destroy();
- } // sos_Object_Bag::close_cursor
-
- // **************************************************************************
- sos_Cursor sos_Object_Bag::duplicate (sos_Cursor c)
- // **************************************************************************
- { sos_Container Cursor_ct = c.container();
- sos_Bag_node bn = sos_Bag_node::make (c.get_current());
- sos_Cursor dup_c = sos_Cursor::create(Cursor_ct, self.get_m());
- sos_Bag_node dup_bn = sos_Bag_node::create(Cursor_ct);
-
- dup_c.set_current (dup_bn);
- dup_bn.set_key_val (bn.get_key_val());
- dup_bn.set_tag_no (bn.get_tag_no());
- dup_bn.set_tag_max (bn.get_tag_max());
- return dup_c;
- } // sos_Object_Bag::duplicate
-
- // **************************************************************************
- sos_Bool sos_Object_Bag::is_valid (sos_Cursor c)
- // **************************************************************************
- { sos_Bool valid = self.get_m().is_valid (c);
- return valid;
- } // ** is_valid **
-
- // **************************************************************************
- sos_Bool sos_Object_Bag::to_first (sos_Cursor c)
- // **************************************************************************
- { sos_Object_sos_Int_Mapping m = self.get_m();
- sos_Bag_node bn = sos_Bag_node::make (c.get_current());
- sos_Container Cursor_ct = c.container();
-
- m.to_first (c);
- if (m.is_valid (c))
- { bn.set_tag_no(1);
- bn.set_tag_max (m.get_info (c));
- }
-
- return m.is_valid (c);
- } // sos_Object_Bag::to_first
-
- // **************************************************************************
- sos_Bool sos_Object_Bag::to_last (sos_Cursor c)
- // **************************************************************************
- { sos_Object_sos_Int_Mapping m = self.get_m();
- sos_Bag_node bn = sos_Bag_node::make (c.get_current());
- sos_Container Cursor_ct = c.container();
-
- m.to_last (c);
- if (m.is_valid (c))
- { sos_Int no = m.get_info (c);
- bn.set_tag_no (no);
- bn.set_tag_max (no);
- }
-
- return m.is_valid (c);
- } // sos_Object_Bag::to_last
-
- // **************************************************************************
- sos_Bool sos_Object_Bag::to_succ (sos_Cursor c, Index steps)
- // **************************************************************************
- { T_PROC ("sos_Object_Bag::to_succ");
- TT (agg_H, T_ENTER);
-
- err_assert (c.defined_for (self.get_m()), "sos_Object_Bag:to_succ");
- err_assert (self.is_valid (c),"sos_Object_Bag:to_succ");
-
- sos_Bag_node bn = sos_Bag_node::make (c.get_current());
- sos_Object o;
- sos_Int no, max;
-
- self.search_succ_pred (bn, steps, o, no, max);
- self.write_current (c, o, no, max);
-
- TT (agg_H, T_LEAVE);
- return self.is_valid (c);
- } // ** sos_Object_Bag::to_succ **
-
- // **************************************************************************
- sos_Bool sos_Object_Bag::to_pred (sos_Cursor c, Index steps)
- // **************************************************************************
- { T_PROC ("sos_Object_Bag::to_pred");
- TT (agg_H, T_ENTER);
-
- err_assert (c.defined_for (self.get_m()), "sos_Object_Bag:to_pred");
- err_assert (self.is_valid (c),"sos_Object_Bag:to_pred");
-
- sos_Bag_node bn = sos_Bag_node::make (c.get_current());
- sos_Object o;
- sos_Int no, max;
-
- self.search_succ_pred (bn,-steps, o, no, max);
- self.write_current (c, o, no, max);
-
- TT (agg_H, T_LEAVE);
- return self.is_valid (c);
- } // ** sos_Object_Bag::to_pred **
-