[AGENT++] Oid::RnCompare()
Karl Abicht
karl at abicht.info
Thu Aug 11 16:50:48 CEST 2005
Hi,
is it possible that this method works correct in the case that both OID have
the same length ?
int Oid::RnCompare(const unsigned long n, const Oid &o) const
{
unsigned long nz = n;
// If both oids are too short, decrease nz
while ((len() < nz) && (o.len() < nz))
nz--;
// oid to compare must have at least the same number of sub-ids to
// comparison else the argument Oid is less than THIS
if (o.len() < nz) return -1;
// also can't compare argument oid for sub-ids which THIS does not have
if (len() < nz) return -1;
int start = (int) (len() -1);
int end = (int) start - (int) nz;
for (int z = start; z > end; z--)
{
if (smival.value.oid.ptr[z] < o.smival.value.oid.ptr[z]) return -1;
if (smival.value.oid.ptr[z] > o.smival.value.oid.ptr[z]) return 1;
}
return 0; // they are equal
Thanks,
Karl
--
Dipl.-Ing. Karl Abicht
Eichenweg 11
25582 Hohenaspe
mailto: karl at abicht.net
phone: +49 4893 373115
mobile: +49 172 4566432
site: http://www.abicht.net
More information about the AGENTPP
mailing list