3 // Author: Phil Mesnier
5 #include "ace/OS_NS_string.h"
8 //-----------------------------------------------------------------------------
10 Sig_List::Sig_List (int cap
)
18 array_
= new Signature
*[capacity_
];
21 Sig_List::~Sig_List ()
23 for (int i
= 0; i
< size_
; i
++)
24 if (array_
[i
]) array_
[i
]->release();
29 Sig_List::add (const ACE_CString
&s
)
31 if (this->index_of (s
) != -1)
35 for (int i
= 0; i
< size_
; i
++)
37 array_
[i
] = new Signature (s
);
41 if (size_
== capacity_
) {
42 int ncap
= capacity_
* 2;
43 Signature
** narray
= new Signature
*[ncap
];
44 ACE_OS::memcpy (narray
,array_
,capacity_
* sizeof(Signature
*));
49 array_
[size_
++] = new Signature(s
);
53 Sig_List::add (const Sig_List
&other
)
55 if (capacity_
< size_
+ other
.capacity_
) {
56 int ncap
= size_
+ other
.capacity_
+ 50;
57 Signature
** narray
= new Signature
*[ncap
];
58 ACE_OS::memcpy (narray
,array_
,capacity_
* sizeof(Signature
*));
64 for (int i
= 0; i
< other
.size_
; i
++)
65 if (other
.array_
[i
] != 0 &&
66 this->index_of (other
.array_
[i
]->name()) == -1)
69 array_
[size_
++] = other
.array_
[i
]->dup();
71 for (int i
= 0; i
< size_
; i
++)
74 array_
[i
] = other
.array_
[i
]->dup();
82 Sig_List::remove (const Signature
&s
)
84 for (int i
= 0; i
< size_
; i
++)
85 if (array_
[i
] && array_
[i
]->name() == s
.name()) {
98 Sig_List::remove_current ()
100 array_
[index_
]->release();
103 if (index_
== size_
- 1)
110 Sig_List::index_of (const Signature
*s
)
112 for (int i
= 0; i
< size_
; i
++)
113 if (array_
[i
] && array_
[i
]->name() == s
->name()) {
121 Sig_List::index_of (const ACE_CString
&s
)
123 for (int i
= 0; i
< size_
; i
++)
124 if (array_
[i
] && array_
[i
]->name() == s
) {
134 for (index_
= 0; index_
< size_
; index_
++)
135 if (array_
[index_
] != 0)
136 return array_
[index_
];
143 for (++index_
; index_
< size_
; index_
++)
144 if (array_
[index_
] != 0)
145 return array_
[index_
];
152 return index_
< size_
;
168 for (int i
= 0; i
< size_
; i
++)
169 if (array_
[i
] != 0) {
171 array_
[insert
] = array_
[i
];