Skip to content

Commit 1f81fa4

Browse files
committed
添加 xy_seq_find()
1 parent 4b11ee3 commit 1f81fa4

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

lib/xy.h

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* | Mikachu2333 <[email protected]>
99
* |
1010
* Created On : <2023-08-28>
11-
* Last Modified : <2025-08-21>
11+
* Last Modified : <2025-08-22>
1212
*
1313
*
1414
* xy: 襄阳、咸阳
@@ -22,7 +22,7 @@
2222
#ifndef XY_H
2323
#define XY_H
2424

25-
#define _XY_Version "v0.1.7.0-2025/08/21"
25+
#define _XY_Version "v0.1.7.0-2025/08/22"
2626
#define _XY_Maintain_URL "https://github.com/RubyMetric/chsrc/blob/dev/lib/xy.h"
2727
#define _XY_Maintain_URL2 "https://gitee.com/RubyMetric/chsrc/blob/dev/lib/xy.h"
2828

@@ -1367,6 +1367,25 @@ xy_seq_each (XySeq_t *seq, void (*func)(void *))
13671367
}
13681368
}
13691369

1370+
/**
1371+
* @flavor Ruby: Enumerable#find
1372+
*/
1373+
void *
1374+
xy_seq_find (XySeq_t *seq, bool (*func)(void *))
1375+
{
1376+
xy_cant_be_null (seq);
1377+
xy_cant_be_null (func);
1378+
1379+
for (XySeqItem_t *it = seq->first_item; it; it = it->next)
1380+
{
1381+
if (func (it->data))
1382+
{
1383+
return it->data;
1384+
}
1385+
}
1386+
return NULL;
1387+
}
1388+
13701389

13711390

13721391
#define _XY_Map_Buckets_Count 97

0 commit comments

Comments
 (0)