本文介绍了是(C / C ++等)多维数组的数组褴褛的特殊情况?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个关于是否C ++和C多维数组的好友讨论是衣衫褴褛的数组的特殊情况。有一种观点认为是

I had a discussion with a buddy about whether C++ and C multi-dimensional arrays are special cases of ragged arrays. One point of view was

一个多维阵列不是粗糙的数组,因为多维阵列的每个元件具有相同的大小。在一个参差不齐的阵列,所述至少一个元件具有不同的尺寸比同一阵列的另一元件。 (如果它不具备可能性被衣衫褴褛,它不是一个衣衫褴褛的数组。的)。

的其他角度为

一个多维阵列是粗糙的阵列,其中每个元件具有相同尺寸的一个特例。了刺耳的阵列可以具有不同的大小的行,但不必。 (圆是省略号。的)。

我感兴趣的是得到一个明确的答案,什么是衣衫褴褛阵的一般定义是计算机科学以及是否C和C ++多维数组的数组褴褛与否。

I'm interested in getting a definite answer as to what the common definition of a "ragged array" is in computer science and whether C and C++ multidimensional arrays are ragged arrays or not.

推荐答案

在讨论数学对象,我认为衣衫褴褛可能是用来作为改性剂数组专意味着一个不匹配的次要方面。所以这是第一要义,而不是第二。考虑这样的话摘自 - 我们不说,一个全新的手帕是衣衫褴褛的,因为它有周围的边缘磨损的潜力,但还没有磨损。这不是衣衫褴褛的。所以,如果我们要调用特定阵列衣衫褴褛,我希望这意味着不直。

When discussing mathematical objects, I think that "ragged" is probably used as a modifier to "array" specifically to mean one that has mismatched secondary dimensions. So that's the first meaning rather than the second. Consider where the word is taken from - we don't say that a brand new handkerchief "is ragged, because it has the potential to fray around the edges, but it hasn't frayed yet". It's not ragged at all. So if we were to call a specific array "ragged", I would expect that to mean "not straight".

不过,会有一些情境中,它的价值定义衣衫褴褛阵的意思是潜在的,衣衫褴褛的数组,而不是一个真正确实有不匹配。例如,如果你打算写一个RaggedArray级,你就不会在一个类中不变的设计有保证是一个不匹配的大小的地方,并且一定要抛出一个异常,如果有人试图建立一个与各种规模等于。 ,这将是荒谬的,尽管这一事实,你要调用这个类衣衫褴褛阵列的实例。因此,在这种情况下,与同等尺寸中的所有元素的数组的的一个衣衫褴褛阵的一个特例。这是第二个意义,而不是第一个。

However, there will be some contexts in which it's worth defining "ragged array" to mean a "potentially-ragged array" rather than one that actually does have mismatches. For example, if you were going to write a "RaggedArray" class, you would not design in a class invariant that there is guaranteed to be a mismatched size somewhere, and be sure to throw an exception if someone tries to create one with all sizes equal. That would be absurd, despite that fact that you're going to call instances of this class "ragged arrays". So in that context, an array with equal sizes in all elements is a special case of a "ragged array". That's the second meaning rather than the first.

当然,一个C或C ++多维阵列仍不会这个类的一个实例,但它可能至少满足只读称为RaggedArray一些通用接口的一部分。这基本上是一个捷径,那即使我们知道衣衫褴褛是指具有尺寸不匹配,在大多数情况下,你根本就懒得去调用类或通用接口PotentiallyRaggedArray只是为了清楚,你不会强制约束,必须有之一。

Of course, a C or C++ multi-dimensional array still would not be an instance of this class, but it might satisfy at least the read-only part of some generic interface referred to as "RaggedArray". It's basically a shortcut, that even though we know "ragged" means "having a size mismatch", for most purposes you simply can't be bothered to call that class or generic interface "PotentiallyRaggedArray" just to make clear that you won't enforce the constraint that there must be one.

有之间的类型的特定实例是否具有特定属性的差异,并且类型是否允许它的实例有这种属性,我们常常忽视这种差别,当我们说X类型的实例是X。 X型的实例可能具备的使用性能,这种情况下没有它,所以这种情况下实际上的的可能有两种属性。你的破烂阵列的两种含义可以被看作是该差的一个例子。见E-总理的人群,也维特根斯坦的哲学,因为当我们说一件事就是另一个不同的事情,我们创建了各种困惑。一个实例不是一个类型,以及一个具体的例子不具有相同的电位性质无论它的一个例子。

There's a difference between whether a particular instance of a type has a specific property, and whether the type allows instances of it to have that property, and we frequently ignore that difference when we say that an instance of type X "is an X". Instances of type X potentially have the property, this instance doesn't have it, so this instance in fact does not potentially have the property either. Your two meanings of "ragged array" can be seen as an example of that difference. See the E-Prime crowd, and also the philosophy of Wittgenstein, for the kinds of confusion we create when we say that one thing "is" another, different thing. An instance "is not" a type, and a concrete example does not have the same potential properties as whatever it's an example of.

要具体回答你的问题,我怀疑是有在CS文献一种含义比其他普遍接受preference。那就是你只需要当你把它介绍给定的工作(学术论文,特定库的文档等)来定义自己的目的这些条款之一。如果我能找到两个文件,​​一个使用每个,那么我已经证明了它,但我不能与困扰; - )

To specifically answer your question, I doubt that there is a universally-accepted preference for one meaning over the other in the CS literature. It's one of those terms that you just have to define for your own purposes when you introduce it to a given work (an academic paper, the documentation of a particular library, etc). If I could find two papers, one using each, then I'd have proved it, but I can't be bothered with that ;-)

这篇关于是(C / C ++等)多维数组的数组褴褛的特殊情况?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-02 19:09