From d46eab36df50e53cbe423ac5bf938d4c291bf5d2 Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Tue, 7 Jun 2011 11:47:11 +1000 Subject: Add Find method on RunStyles. --- src/RunStyles.cxx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/RunStyles.cxx') diff --git a/src/RunStyles.cxx b/src/RunStyles.cxx index 93688b3f9..643d2fb2d 100644 --- a/src/RunStyles.cxx +++ b/src/RunStyles.cxx @@ -233,3 +233,18 @@ bool RunStyles::AllSame() const { bool RunStyles::AllSameAs(int value) const { return AllSame() && (styles->ValueAt(0) == value); } + +int RunStyles::Find(int value, int start) const { + if (start < Length()) { + int run = start ? RunFromPosition(start) : 0; + if (styles->ValueAt(run) == value) + return start; + run++; + while (run < starts->Partitions()) { + if (styles->ValueAt(run) == value) + return starts->PositionFromPartition(run); + run++; + } + } + return -1; +} -- cgit v1.2.3