< T& gt;是什么时候用作方法签名?它是返回类型吗? [英] What does <T> T mean when used as a method signature? Is it a return type?

查看:58
本文介绍了< T& gt;是什么时候用作方法签名?它是返回类型吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

abstract public <T> T iterEdges(EdgeFun<T> func, T accum);

这是用于图形的多线程库.我不要求任何与实际实现有关的东西,我只是不明白双精度返回类型的含义是什么?

This is for a multithreaded library for graphs. I am not asking for anything pertinent to actual implementation whatsoever, I just don't understand what the double return types mean?

我只是在这里猜测,但这是我的解释(我尝试使用谷歌搜索,但Google在非字母数字符号上不匹配,因此我尝试了几种术语组合,但没有任何用处.)

I am just guessing here, but this is my interpretation (I tried googling, but Google doesn't match on non alphanumeric symbols, so I tried a few combinations of terms but didn't get anywhere.)

是说它会返回某种T类型的集合吗?有两个类扩展了此方法所在的类,因此我想它允许多态,但这的真正含义是什么?

It is just saying that it will return some kind of collection of T type? Two classes extend the class that this method is found within, and so I guess it allows for polymorphism, but what is the true meaning of this?

推荐答案

它是

It is a generic method. The first is for the generic type that would be used. The function is also declaring that is returns that type T. The parameters are showing that they use that generic parameter type.

这篇关于&lt; T&amp; gt;是什么时候用作方法签名?它是返回类型吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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