如何计算BitSet对象中的总位数? [英] How to calculate total number of bits in BitSet object?

查看:96
本文介绍了如何计算BitSet对象中的总位数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想计算BitSet对象中的位数.方法length返回BitSet的逻辑大小":BitSet中最高设置位的索引加1,而方法cardinality将给出对象中设置为1的总位数

I want to calculate the total number of bits in a BitSet object. The method length returns the "logical size" of the BitSet: the index of the highest set bit in the BitSet plus one, while method cardinality will give the total number of bits set to 1 in the object.

我想计算包括0和1在内的总位数.我该怎么办?

I want to calculate the total number of bits including both 0s and 1s. How do I do that?

推荐答案

How about BitSet.size()?.....

这篇关于如何计算BitSet对象中的总位数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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