`
leonzhx
  • 浏览: 793323 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

Item 31: Use instance fields instead of ordinals

阅读更多

1.  All enums have an ordinal method, which returns the numerical position of each enum constant in its type.

 

2.  Never derive a value associated with an enum from its ordinal; store it in an instance field instead.

 

3.  ordinal is designed for use by general-purpose enum based data structures such as EnumSet and EnumMap. Unless you are writing such a data structure, you are best off avoiding the ordinal method entirely.

 

分享到:
评论

相关推荐

    Effective Java 3rd edition(Effective Java第三版英文原版)附第二版

    Item 35: Use instance fields instead of ordinals Item 36: Use EnumSet instead of bit fields Item 37: Use EnumMap instead of ordinal indexing Item 38: Emulate extensible enums with interfaces Item 39: ...

    ordinals:用于超限序数计算的脚本集合-开源

    标题中的"ordinals"指的是数学中的序数,这是一种在无限集合上定义的抽象概念,用于描述集合的大小和排列顺序。在数学中,尤其是集合论和逻辑学中,超限序数是比所有自然数更大但仍然有序的序数。它们在理解无限性和...

    RL!dePacker

    is used to force stopping on manual OEP address, use this option ONLY if packer can not be unpacked (the target runs insted of breaking at OEP or dumps at wrong OEP). Generic unpacker can unpack ...

    ImpREC 1.7c

    - Fixed some possible problems on sscanf and ordinals ("%X" with WORD type) v1.5.1 beta2 *PRIVATE* ---------------------- - Tracers - Error codes updated for the Tracers Level2 and 3 - Misc - ...

    Recursive Mathematics - Volume 1 Recursive Model Theory

    It is also a crossroad for several areas of mathematical logic: in set theory it is an initial segment of Godel's L; in model theory, the least admissible set after ; in descriptive set theory, the ...

    Recursive Mathematics - Volume 1 Recursive Model Theory part2

    It is also a crossroad for several areas of mathematical logic: in set theory it is an initial segment of Godel's L; in model theory, the least admissible set after ; in descriptive set theory, the ...

    The Princeton Companion to Mathematics

    Edited by Timothy Gowers, a recipient of the Fields Medal, it presents nearly two hundred entries, written especially for this book by some of the world's leading mathematicians, that introduce basic...

    ansible-enketo:Ansible调查角色

    enketo_repeat_ordinals enketo_validate_continuously 剧本范例 设置Enketo的Playbook可能如下所示: - name: Setup Enketo hosts: enketo-servers enketo_api_salt: "some salt" enketo_api_token:

    Elasticsearch学习笔记1

    在创建或更新索引时,可以通过`PUT /my_index/_settings`命令调整副本数量,例如将`number_of_replicas`设置为1,以控制索引的复制级别。 **索引切换(重命名索引)**是通过`POST /_aliases`操作完成的,这使得在不...

    diablo2 1.13c addresses_windows_diablo2_dll_saidydo_couple396_

    `1.13c Client Function Ordinals.txt`可能列出了客户端相关的函数,这部分可能涉及游戏的图形渲染、用户输入处理、网络通信等关键功能。`1.13c Game Function Ordinals.txt`则可能详细列出了游戏逻辑的函数,包括...

    AMR Guidlines

    11. **序数**(Ordinals):AMR支持序数表示,如“第一”、“第二”。 12. **子集**(Subsets)和**命名实体**(Named Entities):AMR可以表示集合或类别,并识别和处理人名、地名等专有名词。 13. **特殊框架**...

    理论序数可以代替计算机科学中的 ZFC-研究论文

    • Ordinals 理论比 ZFC 强大得多。 在 ZFC 中执行的标准数学可以更轻松地在序数中完成。 ZFC 的公理实际上是序数定理。 Ordinal 类型比 ZFC 中的任何集合都大,因为没有任何集合可以与 Ordinal 类型的实例一一对应...

    wp:白皮书代码

    //kxsys.slack.com/archives/G3CNMRLKC/p1556812534031700enumeration contention enumeration process?ordinals/cardinals,symlinked hdb - symlink to fast disk partitions if available otherwise slower nfs

    序数:序数指示器https:en.m.wikipedia.orgwikiOrdinal_indicator上的开源项目

    项目中的"ordinals-main"可能指的是项目的主代码库或者主要模块,这通常包含了项目的源代码、配置文件、测试用例以及相关的文档。在这个目录下,我们可能会找到一个或多个Java源码文件(如`.java`),这些文件实现了...

    ADOX表对象的正确列序号

    在提供的压缩包文件中,`Correct-Column-Ordinals-of-an-ADOX-Table-Object.pdf`可能是详细的理论文档,它可能解释了如何正确获取列序号的原理和最佳实践。而`ADOXColumnOrdinal_demo.zip`和`ADOXColumnOrdinal_src....

    最新版Elasticsearch调优搜索速度.pdf

    预热全局序数(global ordinals)和filesystem cache可以进一步减少查询延迟,特别是对于具有大量唯一值的字段。 利用索引排序(index sorting)可以加速连接查询,因为预排序的数据在内部查找中更快。使用`...

Global site tag (gtag.js) - Google Analytics