C++中实现动态多维数组模板的分析-03 - 悲催的科学匠人 - 冷水's blog

C++中实现动态多维数组模板的分析-03

冷水 posted @ 2010年12月09日 05:23 in C++ , 1509 阅读

基本上,我计划采用的方案是:

  1. 数据在内部采用一维数组方式存储。这样数据在内存中连续分布,有利于cach命中(其实我也不知道这个名称确切意义)。这对高性能计算这样的应用来说是必须的。
  2. 在数组类中封装若干索引数据,以支持多维指标到一维指标的互相转换。
  3. 索引数据可单独封装为一个类,实现数据和维数表达的分离。以便于多个数组对象之间共享,或者数组维数变化情况。
  4. 索引数据应该尽量的少。C语言中利用指针数组实现多维特性是不可以接收的,因为指针数组的维数只比数据数组的维数少了一维而已。当数组很大时(比如要几个G的空间),指针数组也很大,造成空间浪费。在我所考虑的方案中,对于数组[L][M][N],只需要L+M+N个size_t类型的索引。因此,即使L*M*N很大(比如1000*1000*1000),L+M+N(才3000而已)也很小。
  5. 目前不打算支持动态的数组尺寸。但是当基本功能实现之后,这个特性应该不难扩展。
  • 无匹配
  • 无匹配
Avatar_small
civaget 说:
2023年12月10日 09:02

The mobile optimization aspect of 구글 seo is non-negotiable in an era where mobile-first indexing takes center stage.

Avatar_small
civaget 说:
2023年12月16日 01:20

Don't let scams ruin your gaming fun. Depend on 먹튀검증 for a secure experience.

Avatar_small
civaget 说:
2023年12月23日 09:02 안산휴게텔's decor exudes serenity and elegance.
Avatar_small
civaget 说:
2023年12月26日 04:00

Reliability is the key, and 축구중계 unlocks a world of soccer without interruptions.

Avatar_small
civaget 说:
2024年1月06日 01:29

I rely on 오피가이드 for up-to-date KOREA information.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter
Host by is-Programmer.com | Power by Chito 1.3.3 beta | © 2007 LinuxGem | Design by Matthew "Agent Spork" McGee