Mercurial > hg > octave-lyh
changeset 3767:f0e7c832e0e2
[project @ 2001-01-29 16:32:08 by jwe]
author | jwe |
---|---|
date | Mon, 29 Jan 2001 16:32:08 +0000 |
parents | df962bbf1788 |
children | 243148f6c91c |
files | liboctave/ChangeLog src/ChangeLog src/Map.cc src/Map.h |
diffstat | 4 files changed, 70 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,7 @@ +2001-01-29 John W. Eaton <jwe@bevo.che.wisc.edu> + + * lo-cutils.c: Don't delcare strptime. + 2001-01-02 John W. Eaton <jwe@bevo.che.wisc.edu> * CMatrix.cc (operator * (const ComplexMatrix&, const ComplexMatrix&):
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,17 @@ +2001-01-29 John W. Eaton <jwe@bevo.che.wisc.edu> + + * Map.h, Map.cc (CHMap<C>::operator = (const CHMap&)): New function. + (Map<C>::operator = (const Map&)): Likewise. + (Map<C> (const Map&)): Likewise. + + * OPERATORS/op-cm-cs.cc, OPERATORS/op-cm-s.cc, + OPERATORS/op-m-cs.cc, OPERATORS/op-m-s.cc: + Make ldiv operator work for row vector by scalar ops. + + * OPERATORS/op-cs-cm.cc, OPERATORS/op-cs-m.cc, + OPERATORS/op-s-cm.cc, OPERATORS/op-s-m.cc: + Make div operator work for scalar by column vector ops. + 2001-01-17 John W. Eaton <jwe@bevo.che.wisc.edu> * parse.y (safe_fclose): Discard comments at the end of a file.
--- a/src/Map.cc +++ b/src/Map.cc @@ -132,6 +132,42 @@ } template <class C> +CHMap<C>& +CHMap<C>::operator = (const CHMap& a) +{ + Map<C>::operator = (*this); + + unsigned int old_size = a.size; + + CHNode<C> **old_tab = tab; + old_size = a.size; + + size = old_size; + tab = new CHNode<C>* [size]; + + for (unsigned int i = 0; i < size; ++i) + tab[i] = static_cast<CHNode<C> *> (index_to_CHptr (i+1)); + + for (Pix p = a.first (); p; a.next (p)) + (*this) [a.key (p)] = a.contents (p); + + for (unsigned int i = 0; i < old_size; ++i) + { + CHNode<C> *p = old_tab[i]; + old_tab[i] = static_cast<CHNode<C> *> (index_to_CHptr (i+1)); + while (p->goodCHptr ()) + { + CHNode<C> *nxt = p->tl; + delete p; + p = nxt; + } + } + delete [] old_tab; + + return *this; +} + +template <class C> Pix CHMap<C>::seek (const std::string& key) const {
--- a/src/Map.h +++ b/src/Map.h @@ -53,7 +53,17 @@ C def; public: - Map (const C& dflt) : def (dflt) { count = 0; } + Map (const C& dflt) : count (0), def (dflt) { } + + Map (const Map& m) : count (m.count), def (m.def) { } + + Map& operator = (const Map& m) + { + count = m.count; + def = m.def; + + return *this; + } virtual ~Map (void) { } @@ -125,10 +135,12 @@ CHMap (const CHMap& a); + CHMap& operator = (const CHMap& a); + ~CHMap (void) { clear (); - delete tab; + delete [] tab; } C& operator [] (const std::string& key); @@ -151,8 +163,8 @@ if (p == 0) error ("null Pix"); - return ((CHNode<C> *) p)->cont; - } + return ((CHNode<C> *) p)->cont; + } Pix seek (const std::string& key) const;