百度360必应搜狗淘宝本站头条
当前位置:网站首页 > 编程网 > 正文

vbnet 位数组bitarray vb中数组排序的方法

yuyutoo 2024-10-12 01:35 16 浏览 0 评论

BitArray类管理位值的压缩数组,它表示为布尔值,其中true表示该位为(1),false表示位为off(0)。

它用于需要存储位但不提前知道位数。 您可以通过使用从零开始的整数索引来访问BitArray集合中的项目。

BitArray类的属性和方法

下表列出了BitArray类的一些常用属性:

属性 描述

Count Gets the number of elements contained in the BitArray.

获取BitArray中包含的元素数。

IsReadOnly Gets a value indicating whether the BitArray is read-only.

获取一个指示BitArray是否为只读的值。

Item Gets or sets the value of the bit at a specific position in the BitArray.

获取或设置位在BitArray中特定位置的值。

Length Gets or sets the number of elements in the BitArray.

获取或设置BitArray中的元素数。

下表列出了BitArray类的一些常用方法:

S.N 方法名称和用途

1

Public Function And (value As BitArray) As BitArray

Performs the bitwise AND operation on the elements in the current BitArray against the corresponding elements in the specified BitArray.

对当前BitArray中的元素与指定的BitArray中的相应元素执行按位AND运算。

2

Public Function Get (index As Integer) As Boolean

Gets the value of the bit at a specific position in the BitArray.

获取位在BitArray中特定位置的值。

3

Public Function Not As BitArray

Inverts all the bit values in the current BitArray, so that elements set to true are changed to false, and elements set to false are changed to true.

反转当前BitArray中的所有位值,以便将设置为true的元素更改为false,将设置为false的元素更改为true。

4

Public Function Or (value As BitArray) As BitArray

Performs the bitwise OR operation on the elements in the current BitArray against the corresponding elements in the specified BitArray.

对当前BitArray中的元素与指定的BitArray中的相应元素执行按位或运算。

5

Public Sub Set (index As Integer, value As Boolean )

Sets the bit at a specific position in the BitArray to the specified value.

将BitArray中特定位置的位设置为指定值。

6

Public Sub SetAll (value As Boolean)

Sets all bits in the BitArray to the specified value.

将BitArray中的所有位设置为指定的值。

7

Public Function Xor (value As BitArray) As BitArray

Performs the bitwise eXclusive OR operation on the elements in the current BitArray against the corresponding elements in the specified BitArray.

对当前BitArray中的元素与指定的BitArray中的相应元素执行逐位异或操作。

示例:

下面的例子演示了使用BitArray类:

Module collections

Sub Main()

'creating two bit arrays of size 8

Dim ba1 As BitArray = New BitArray(8)

Dim ba2 As BitArray = New BitArray(8)

Dim a() As Byte = {60}

Dim b() As Byte = {13}

'storing the values 60, and 13 into the bit arrays

ba1 = New BitArray(a)

ba2 = New BitArray(b)

'content of ba1

Console.WriteLine("Bit array ba1: 60")

Dim i As Integer

For i = 0 To ba1.Count

Console.Write("{0 } ", ba1(i))

Next i

Console.WriteLine()

'content of ba2

Console.WriteLine("Bit array ba2: 13")

For i = 0 To ba2.Count

Console.Write("{0 } ", ba2(i))

Next i

Console.WriteLine()

Dim ba3 As BitArray = New BitArray(8)

ba3 = ba1.And(ba2)

'content of ba3

Console.WriteLine("Bit array ba3 after AND operation: 12")

For i = 0 To ba3.Count

Console.Write("{0 } ", ba3(i))

Next i

Console.WriteLine()

ba3 = ba1.Or(ba2)

'content of ba3

Console.WriteLine("Bit array ba3 after OR operation: 61")

For i = 0 To ba3.Count

Console.Write("{0 } ", ba3(i))

Next i

Console.WriteLine()

Console.ReadKey()

End Sub

End Module

当上述代码被编译和执行时,它产生以下结果:

Bit array ba1: 60

False False True True True True False False

Bit array ba2: 13

True False True True False False False False

Bit array ba3 after AND operation: 12

False False True True False False False False

Bit array ba3 after OR operation: 61

True False True True False False False False

相关推荐

电脑 CMD 命令大全:简单粗暴收藏版

电脑CMD命令大全包括了许多常用的命令,这些命令可以帮助用户进行各种系统管理和操作任务。以下是一些常用的CMD命令及其功能:1、系统信息和管理...

电脑维修高手必备!8个神奇DOS命令,自己动手不求人

我相信搞电脑维修或者维护的基本都会些DOS的命令。就算Windows操作系统是可视化的界面,但很多维护检查是离不开DOS命令的。掌握好这些命令,你不仅能快速诊断问题,还能解决90%的常见电脑故障。下...

一个互联网产品总监的设计技巧总结 - 技术篇

古语:工欲善其事必先利其器。往往在利其器后我们才能事半功倍。从这个角度出发成为一个合格的产品经理你需要的是“利其器”,这样你才能产品的设计过程中如鱼得水,得心应手。有些产品经理刚入职,什么都感觉自己欠...

超详解析Flutter渲染引擎|业务想创新,不了解底层原理怎么行?

作者|万红波(远湖)出品|阿里巴巴新零售淘系技术部前言Flutter作为一个跨平台的应用框架,诞生之后,就被高度关注。它通过自绘UI,解决了之前RN和weex方案难以解决的多端一致性...

瑞芯微RK3568|SDK开发之环境安装及编译操作

1.SDK简介一个通用LinuxSDK工程目录包含有buildroot、app、kernel、device、docs、external等目录。其中一些特性芯片如RK3308/RV1108/R...

且看L-MEM ECC如何守护i.MXRT1170从核CM4

大家好,我是痞子衡,是正经搞技术的痞子。今天痞子衡给大家分享的是恩智浦i.MXRT1170上Cortex-M4内核的L-MEMECC功能。本篇是《简析i.MXRT1170Cortex-M7F...

ECC给i.MXRT1170 FlexRAM带来了哪些变化?

大家好,我是痞子衡,是正经搞技术的痞子。今天痞子衡给大家分享的是恩智浦i.MXRT1170上Cortex-M7内核的FlexRAMECC功能。ECC是“ErrorCorrectingCode”...

PHP防火墙代码,防火墙,网站防火墙,WAF防火墙,PHP防火墙大全

PHP防火墙代码,防火墙,网站防火墙,WAF防火墙,PHP防火墙大全资源宝整理分享:https://www.htple.net...

从零开始移植最新版本(2023.10)主线Uboot到Orange Pi 3(全志H6)

本文将从零开始通过一步一步操作来实现将主线U-Boot最新代码移植到OrangePi3(全志H6)开发板上并正常运行起来。本文从通用移植思路的角度,展现是思考的过程,通过这种方式希望能让读者一通百...

可视化编程工具Blockly——定制工具箱

1概述本文重点讲解如何定制Blocklytoolbox上,主要包含如下几点目标:如何为toolbox不同类别添加背景色如何改变选中的类别的外观如何为toolbox类别添加定制化的css如何改变类别...

用户界面干货盘点(用户界面的基本操作方法)

DevExpressDevExpressWPF的DXSplashScreen控件在应用加载的时候显示一个启动界面。添加DXSplashScreen后,会默认生成一个XAML文件,当然,你也可...

Vue3+Bootstrap5整合:企业级后台管理系统实战

简洁而不简单,优雅而不失强大在当今快速发展的企业数字化进程中,高效、美观的后台管理系统已成为企业运营的核心支撑。作为前端开发者,我们如何选择技术栈,才能既保证开发效率,又能打造出专业级的用户体验?答案...

什么?这三款i.MXRT型号也开放了IAP API?

大家好,我是痞子衡,是正经搞技术的痞子。今天痞子衡给大家介绍的是i.MXRT1050/1020/1015系列ROM中的FlexSPI驱动API使用。今天痞子衡去4S店给爱车做保养了,...

OneCode基础组件介绍——表格组件(Grid)

在企业级应用开发中,表格组件是数据展示与交互的核心载体。OneCode平台自研的Grid表格组件,以模型驱动设计...

开源无线LoRa传感器(光照温湿度甲醛Tvoc)

本开源项目基于ShineBlinkC2M低代码单片机实现,无需复杂单片机C语言开发。即使新手也可很容易用FlexLua零门槛开发各种功能丰富稳定可靠的IoT硬件,更多学习教程可参考Flex...

取消回复欢迎 发表评论: