comparison liboctave/str-vec.cc @ 2941:b779a5b8aed4

[project @ 1997-05-08 02:14:34 by jwe]
author jwe
date Thu, 08 May 1997 02:17:52 +0000
parents c05d4e1a9bee
children 443851377f3f
comparison
equal deleted inserted replaced
2940:c05d4e1a9bee 2941:b779a5b8aed4
62 string_vector::string_vector (const char * const *s, int n) 62 string_vector::string_vector (const char * const *s, int n)
63 : Array<string> (n) 63 : Array<string> (n)
64 { 64 {
65 for (int i = 0; i < n; i++) 65 for (int i = 0; i < n; i++)
66 elem (i) = s[i]; 66 elem (i) = s[i];
67 }
68
69 string_vector&
70 string_vector::uniq (void)
71 {
72 int len = length ();
73
74 if (len > 0)
75 {
76 int k = 0;
77
78 for (int i = 1; i < len; i++)
79 if (elem(i) != elem(k))
80 if (++k != i)
81 elem(k) = elem(i);
82
83 if (len != ++k)
84 resize (k);
85 }
86
87 return *this;
67 } 88 }
68 89
69 char ** 90 char **
70 string_vector::c_str_vec (void) const 91 string_vector::c_str_vec (void) const
71 { 92 {