OptionalContentGroup* OCGs::findOcgByRef( const Ref &ref) { //TODO: make this more efficient OptionalContentGroup *ocg = NULL; for (int i=0; i < optionalContentGroups->getLength(); ++i) { ocg = (OptionalContentGroup*)optionalContentGroups->get(i); if ( (ocg->getRef().num == ref.num) && (ocg->getRef().gen == ref.gen) ) { return ocg; } } error(-1, "Could not find a OCG with Ref (%d:%d)", ref.num, ref.gen); // not found return NULL; }