pespin has submitted this change. ( 
https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/41962?usp=email )

Change subject: Osmocom_Types: Add API ro_integer_get_first_pos()
......................................................................

Osmocom_Types: Add API ro_integer_get_first_pos()

It is sometimes useful to find out the position of the 1st item (only
one if the list is expected to be a set of unique items), in order to
update extra state on an external list.t

Change-Id: Id70b2c7d6bf702489de03aed1c389ae892aee835
---
M library/Osmocom_Types.ttcn
1 file changed, 9 insertions(+), 3 deletions(-)

Approvals:
  Jenkins Builder: Verified
  osmith: Looks good to me, but someone else must approve
  fixeria: Looks good to me, approved




diff --git a/library/Osmocom_Types.ttcn b/library/Osmocom_Types.ttcn
index 690535c..6fbcb39 100644
--- a/library/Osmocom_Types.ttcn
+++ b/library/Osmocom_Types.ttcn
@@ -401,13 +401,19 @@

 type record of integer ro_integer;

-function ro_integer_contains(ro_integer r, integer x) return boolean {
+/* returns position of "x" in "r", -1 otherwise. */
+function ro_integer_get_first_pos(ro_integer r, integer x) return integer {
        for (var integer j := 0; j < lengthof(r); j := j+1) {
                if (r[j] == x) {
-                       return true;
+                       return j;
                }
        }
-       return false;
+       return -1;
+}
+
+
+function ro_integer_contains(ro_integer r, integer x) return boolean {
+       return ro_integer_get_first_pos(r, x) != -1;
 }

 function ro_integer_add_unique(inout ro_integer roi, integer new_entry)

--
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/41962?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: Id70b2c7d6bf702489de03aed1c389ae892aee835
Gerrit-Change-Number: 41962
Gerrit-PatchSet: 2
Gerrit-Owner: pespin <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <[email protected]>
Gerrit-Reviewer: osmith <[email protected]>
Gerrit-Reviewer: pespin <[email protected]>

Reply via email to