---
title: Compare结构体
description: "比较请求体对象的序列号大小，根据第一个参数请求体数据类型进行区分。"
url: https://www.hiascend.com/document/detail/zh/mindie/latest/mindiellm/llmdev/mindie_llm0148.html
sourcePath: /source/zh/mindie/310/mindiellm/llmdev/mindie_llm0148.html
indexId: 3f2413d6fe7256c72b82364e16c471781ea4d04f978c6fb4cc39b733fa246e9958
---
# Compare结构体

#### 结构体功能

比较请求体对象的序列号大小，根据第一个参数请求体数据类型进行区分。

- 若请求体序列号为string类型，则比较请求体对象序列号的hash值大小；
- 若请求体序列号对象为数值类型，则比较其数值大小。

最后返回两个请求体的序列号大小关系，若结果为true，第一个参数的请求对象序列号值大；若结果为false，第一个参数的请求体对象序列号值小于等于第二个参数请求体对象序列号值。


#### 结构体格式

```
struct Compare {
bool operator () (const InferRequestId &lhs, const InferRequestId &rhs) const
{
if (lhs.Type() == InferRequestId::DataType::STRING) {
return std::hash<std::string>()(lhs.StringValue()) < std::hash<std::string>()(rhs.StringValue());
} else {
return lhs.UnsignedIntValue() < rhs.UnsignedIntValue();
}
}
};
```


#### 结构体参数

无。
