从部分字符串中查找全局原子 [英] Find a Global Atom from a partial string

查看:17
本文介绍了从部分字符串中查找全局原子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用 GlobalAddAtom 创建一个全局原子,如果我已经知道与原子关联的字符串,我可以使用 GlobalFindAtom 再次找到该原子.但是有没有办法找到关联字符串与给定部分字符串匹配的所有原子?

I can create an Global Atom using GlobalAddAtom and I can find that atom again using GlobalFindAtom if I already know the string associated with the atom. But is there a way to find all atoms whose associated string matches a given partial string?

例如,假设我有一个原子,它的字符串是Hello, World!"我以后如何通过仅搜索Hello"来找到该原子?

For example, let's say I have an atom whose string is "Hello, World!" How can I later find that atom by searching for just "Hello"?

推荐答案

不幸的是,您描述的行为不适用于 Atom Tables.这是因为 Windows 中的 Atom 表基本上是哈希表,映射过程是整体处理字符串而不是部分处理.

Unfortunately, the behavior you're describing is not possible for Atom Tables. This is because Atom Tables in Windows are basically Hash Tables, and the mapping process handles strings in entirety and not by parts.

当然,这听起来几乎是可能的,正如引用自 MSDN 文档:

Of course, it almost sounds like it would be possible, as quoted from the MSDN documentation:

应用程序还可以使用本地原子表来节省搜索特定字符串的时间.要执行搜索,应用程序只需将搜索字符串放在原子表中,并将结果原子与相关结构中的原子进行比较.比较原子通常比比较字符串更快.

但是,它们指的是完全匹配.与当前可用于软件的资源相比,这种限制似乎已经过时了.然而,Atoms 早在 Win16 就已经可用,在那个时候,这个工具允许应用程序在最少的内存中有效地管理字符串数据.现在仍然使用原子来管理窗口类名,并且在减少字符串的多个存储副本的占用空间方面仍然提供了不错的好处.

However, they are referring to exact matches. This limitation probably seems dated compared to what is possible with resources currently available to software. However, Atoms have been available as far back as Win16 and in those times, this facility allowed a means for applications to manage string data effectively in minimal memory. Atoms are still used now to manage window class names, and still provide decent benefits in reducing the footprint of multiple stored copies of strings.

如果您需要有效地存储字符串数据并能够通过部分起始匹配进行扫描,后缀树 很可能满足或超过您的需求.

If you need to store string data efficiently and to be able to scan by partial starting matches, a Suffix Tree is likely to meet or exceed your needs.

这篇关于从部分字符串中查找全局原子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆