# HG changeset patch # User jwe # Date 769211155 0 # Node ID 7479f36341f9e27374db11f232ab63f789246c1e # Parent 6f08c8b8f62f71d39ab5199df4bec9a24134b779 [project @ 1994-05-17 21:45:55 by jwe] diff --git a/liboctave/idx-vector.cc b/liboctave/idx-vector.cc --- 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) {