添加 xy_seq_find()

This commit is contained in:
Aoran Zeng 2025-08-22 11:23:19 +08:00
parent 4b11ee3d8b
commit 1f81fa4efc
No known key found for this signature in database
GPG Key ID: 8F8BA8488E10ED98

View File

@ -8,7 +8,7 @@
* | Mikachu2333 <mikachu.23333@zohomail.com>
* |
* Created On : <2023-08-28>
* Last Modified : <2025-08-21>
* Last Modified : <2025-08-22>
*
*
* xy:
@ -22,7 +22,7 @@
#ifndef XY_H
#define XY_H
#define _XY_Version "v0.1.7.0-2025/08/21"
#define _XY_Version "v0.1.7.0-2025/08/22"
#define _XY_Maintain_URL "https://github.com/RubyMetric/chsrc/blob/dev/lib/xy.h"
#define _XY_Maintain_URL2 "https://gitee.com/RubyMetric/chsrc/blob/dev/lib/xy.h"
@ -1367,6 +1367,25 @@ xy_seq_each (XySeq_t *seq, void (*func)(void *))
}
}
/**
* @flavor Ruby: Enumerable#find
*/
void *
xy_seq_find (XySeq_t *seq, bool (*func)(void *))
{
xy_cant_be_null (seq);
xy_cant_be_null (func);
for (XySeqItem_t *it = seq->first_item; it; it = it->next)
{
if (func (it->data))
{
return it->data;
}
}
return NULL;
}
#define _XY_Map_Buckets_Count 97