是一个无限枚举仍与QUOT;枚举"? [英] Is an infinite enumerable still "enumerable"?

查看:211
本文介绍了是一个无限枚举仍与QUOT;枚举"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

就像两个重叠的线段,我们可以找到交集点无限。要列举所有这些问题可能没有什么意义,我们可能只是想提出这个集合是无穷大。



浮点数定义 NegativeInfinity PositiveInfinity时。这代表一个数字的计数的似乎没有必要使用浮点数,但整数没有定义的东西来代表无穷大。



于是,我就实现无限枚举。但是,我突然得到与术语枚举..



有没有更好的办法来解决这个问题困惑?而且是一个无限枚举仍枚举的?




  • 代码



     公共部分类无穷远:IEnumerable的<对象> {
    &的IEnumerator LT;对象> IEnumerable的<对象> .GetEnumerator(){
    为(;)
    收益率的回报Infinity.Enumerable;
    }

    公众的IEnumerator的GetEnumerator(){
    为(;)
    收益率的回报Infinity.Enumerable;
    }

    公众无限LongCount(
    Func键<对象,布尔>谓语=默认(Func键<对象,布尔>)){
    返回Infinity.Enumerable;
    }

    公众无限计数(
    Func键<对象,布尔>谓语=默认(Func键<对象,布尔>)){
    返回Infinity.Enumerable;
    }

    公共静态只读无限可枚举=新的无限();
    }







编辑:



谢谢回答。我的不可以的IEnumerable 的IEnumerator 混淆。 的GetEnumerator 方法返回 Infinity.Enumerable 是因为我做的不可以要声明一个额外的虚拟对象,例如:

 静态只读对象哑=新的对象(); 

和收益回报的GetEnumerator 方法。


解决方案

和是一个无限枚举仍然枚举?




可枚举,在这个意义上说,是根据关的枚举<第二定义/ A>:




要指定一个又一个




它不是指定义(计算的更常见的外),由此它实际上意味着能够被计算在内。



在这个意义上,一个无限系列绝对可以陆续上市一个项目,有资格作为一个枚举。



话虽这么说,我看不出在这个例子中的代码背后的目的。无限可枚举通常代表像数据流没有结束,或其他来源那里没有结束,但潜在的不断拉的信息。


Like two overlapping line segments, we can find infinite points of intersection. To enumerate all these points might not make sense, and we might just want to present that this collection is infinity.

Floating point numbers have defined NegativeInfinity and PositiveInfinity. A number which represents count or ordinal seem not necessary to use floating point numbers, however, integers are not defined something to represent infinity.

So I tried to implement an infinite enumerable. But I suddenly get confused with the term "enumerable" ..

Is there a better way to solve this problem? And is an infinite enumerable still enumerable?

  • Code

    public partial class Infinity: IEnumerable<object> {
        IEnumerator<object> IEnumerable<object>.GetEnumerator() {
            for(; ; )
                yield return Infinity.Enumerable;
        }
    
        public IEnumerator GetEnumerator() {
            for(; ; )
                yield return Infinity.Enumerable;
        }
    
        public Infinity LongCount(
            Func<object, bool> predicate=default(Func<object, bool>)) {
            return Infinity.Enumerable;
        }
    
        public Infinity Count(
            Func<object, bool> predicate=default(Func<object, bool>)) {
            return Infinity.Enumerable;
        }
    
        public static readonly Infinity Enumerable=new Infinity();
    }
    


Edit:

Thanks for answering. I'm not confused with IEnumerable and IEnumerator. GetEnumerator methods return Infinity.Enumerable is because I do not want to declare an extra dummy object such as:

static readonly object dummy=new object();

and yield return dummy in GetEnumerator methods.

解决方案

And is an infinite enumerable still enumerable?

Enumerable, in this sense, is based off the second definition of enumerate:

to specify one after another

It is not referring to the (more common outside of computing) definition whereby it effectively means "able to be counted."

In this sense, an infinite series can definitely be listed one item after another, and qualifies as an enumerable.

That being said, I don't see the purpose behind your code in this example. Infinite enumerables are typically representing something like a stream of data without an end, or other sources where there is no "end", but the potential to continually pull information.

这篇关于是一个无限枚举仍与QUOT;枚举&QUOT;?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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