Mercurial > hg > octave-nkf
changeset 417:7479f36341f9
[project @ 1994-05-17 21:45:55 by jwe]
author | jwe |
---|---|
date | Tue, 17 May 1994 21:45:55 +0000 |
parents | 6f08c8b8f62f |
children | c18892d88a17 |
files | liboctave/idx-vector.cc |
diffstat | 1 files changed, 25 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/idx-vector.cc +++ b/liboctave/idx-vector.cc @@ -1,7 +1,7 @@ // Very simple integer vectors for indexing -*- C++ -*- /* -Copyright (C) 1992, 1993 John W. Eaton +Copyright (C) 1992, 1993, 1994 John W. Eaton This file is part of Octave. @@ -289,6 +289,30 @@ (int (*)(void*, void*)) intcmp); } +void +idx_vector::sort_uniq (void) +{ + if (len > 0) + { + sort (); + + int *new_data = new int [len]; + new_data[0] = data[0]; + int k = 0; + for (int i = 1; i < len; i++) + { + if (data[i] != new_data[k]) + { + k++; + new_data[k] = data[i]; + } + } + delete [] data; + len = k+1; + data = new_data; + } +} + ostream& operator << (ostream& os, const idx_vector& a) {