当前位置:网站首页>Why does the subscript of the array start from 0 instead of 1?
Why does the subscript of the array start from 0 instead of 1?
2022-04-23 06:07:00 【New ape and horse】
Catalog
Two Array model representation
3、 ... and Array addressing calculation
One Array addressing formula
a[i]_address = base_address + i * data_type_size
data_type_size Is the size of each element in the array .
Two Array model representation
With int[] a = new int[10] For example . Computers give arrays a[10], Allocated a contiguous memory space 2000~2039, The first address of the memory block is base_address = 2000.

3、 ... and Array addressing calculation
Suppose the array is from 0 Start , Computation first 9 The first element formula is :a[9]_address = 2000 + 9 * 4 = 2036;
Suppose the array is from 1 Start , Computation first 9 The first element formula is :a[9]_address = 2000 + (10-1) * 4 = 2036
contrast : Array from 1 At first, it is equivalent to one more subtraction operation for each random access to array elements , about CPU Come on , Just one more subtraction instruction . Arrays are very basic data structures , Random access to array elements through subscripts is a very basic programming operation , The optimization of efficiency should be as extreme as possible .
Conclusion : In order to reduce one subtraction operation , Array selected from 0 Numbered starting , Not from 1 Start .
版权声明
本文为[New ape and horse]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220533487760.html
边栏推荐
- 对比学习论文——[MoCo,CVPR2020]Momentum Contrast for Unsupervised Visual Representation Learning
- 自動控制(韓敏版)
- Reading of denoising paper - [ridnet, iccv19] real image denoising with feature attention
- 创建企业邮箱账户命令
- 图像恢复论文——[RED-Net, NIPS16]Image Restoration Using Very Deep Convolutional Encoder-Decoder Networks wi
- Pytorch学习记录(十二):学习率衰减+正则化
- Exception handling: grab and throw model
- 自动控制(韩敏版)
- Chapter 4 of line generation - linear correlation of vector systems
- Programming record - picture rotation function SciPy ndimage. Simple use and effect observation of rotate()
猜你喜欢
![去噪论文——[Noise2Void,CVPR19]Noise2Void-Learning Denoising from Single Noisy Images](/img/9d/487c77b5d25d3e37fb629164c804e2.png)
去噪论文——[Noise2Void,CVPR19]Noise2Void-Learning Denoising from Single Noisy Images

sklearn之 Gaussian Processes

Font shape `OMX/cmex/m/n‘ in size <10.53937> not available (Font) size <10.95> substituted.

Multithreading and high concurrency (3) -- synchronized principle

Explain of MySQL optimization

线性代数第一章-行列式

Pytoch -- data loading and processing

Font shape `OMX/cmex/m/n‘ in size <10.53937> not available (Font) size <10.95> substituted.

On traversal of binary tree

PyQy5学习(四):QAbstractButton+QRadioButton+QCheckBox
随机推荐
ValueError: loaded state dict contains a parameter group that doesn‘t match the size of optimizer‘s
对比学习论文——[MoCo,CVPR2020]Momentum Contrast for Unsupervised Visual Representation Learning
关于二叉树的遍历
Manually delete registered services on Eureka
Traitement des séquelles du flux de Tensor - exemple simple d'enregistrement de torche. Utils. Données. Dataset. Problème de dimension de l'image lors de la réécriture de l'ensemble de données
Ptorch learning record (XIII): recurrent neural network
Custom exception class
Solution record of slow access speed of SMB service in redhat6
Fundamentals of SQL: first knowledge of database and SQL - installation and basic introduction - Alibaba cloud Tianchi
Fundamentals of digital image processing (Gonzalez) I
How to use comparative learning to do unsupervised - [cvpr22] training & [eccv20] image translation
Reading of denoising papers - [cvpr2022] blind2blind: self supervised image denoising with visible blind spots
去噪论文阅读——[CVPR2022]Blind2Unblind: Self-Supervised Image Denoising with Visible Blind Spots
你不能访问此共享文件夹,因为你组织的安全策略阻止未经身份验证的来宾访问
Pyemd installation and simple use
Pytorch学习记录(九):Pytorch中卷积神经网络
rsync实现文件服务器备份
EditorConfig
Illustrate the significance of hashcode
ValueError: loaded state dict contains a parameter group that doesn‘t match the size of optimizer‘s