由买买提看人间百态

topics

全部话题 - 话题: generics
首页 上页 1 2 3 4 5 6 7 8 9 10 下页 末页 (共10页)
s***8
发帖数: 1136
1
来自主题: Java版 - Question: reflection and generics
Thanks!
I've omitted methods inherited from Object. The part I don't understand is,
why hello method appears twice. Aren't they the same method, since
HelloImpl just implements the same method declared in GenericIntf?
If I don't use any generics, let HelloImpl implement Runnable interface, the
run() mehtod only appear once when reflecting on HelloImpl.
q*********u
发帖数: 280
2
来自主题: Java版 - Question: reflection and generics
I believe T yourMethod() and String yourMethod() are diferent.
According to 'Thinking in Java', I remember before 1.5, java use generic '
Object' as 'T';

is,
the
l*********s
发帖数: 5409
3
A syntax question when writing generic sorted linked list type:
How to specify that the implements comparable interface so it knows the
sense of "larger"/"smaller" ?
l*********s
发帖数: 5409
4
来自主题: Java版 - generic 太长怎么办?
在写程序时候所有java generic type变量声明都要写全generic的
类型参数么?这也太麻烦了,能不能忽略eclipse的警告阿?
x****a
发帖数: 1229
5
在新建的stack中,引用generic method
public E remove()方法出错。
没办法,怕问题说不清楚,才贴的大段。老师写的code,都是linked list型的,一个
扯着一个的。
l*********s
发帖数: 5409
6
the problem is that Java generic must be object, not prototype like int,
float, etc. You shall use Integer class .
x****a
发帖数: 1229
7
I see. It compiled successfully when I changed the pop() method in the stack
class with generic type.thanks.
public int pop()>>>>>>>>>>>public E pop(), then invoke public E remove().
One more question, how to deal with null pointer exception problem with
doublyLinkedList- type stack after I pop all the elements.
It shows error at "((DLNode)target.getSuccessor()).setPredecessor(target.
getPredecessor());"
My silly solution is to push one more element when stack.isEmpty to avoid
the situation. ... 阅读全帖
f*******n
发帖数: 12623
8
No, all generics are erased after compiling. There is no T. Anything you can
get you must get from stuff that you have at runtime.
Think about it, after type erasure your class looks like this:
public class GenericReflection
{
private Object object;
//---- get/set ---
public void setObject( Object v ){ object=v; }
public Object getObject(){ return object; }
//---- is it possible to get the class for the object? ----
public Class getObjectClass()
{
Class retval = null;

if... 阅读全帖
f*******n
发帖数: 12623
9
No, all generics are erased after compiling. There is no T. Anything you can
get you must get from stuff that you have at runtime.
Think about it, after type erasure your class looks like this:
public class GenericReflection
{
private Object object;
//---- get/set ---
public void setObject( Object v ){ object=v; }
public Object getObject(){ return object; }
//---- is it possible to get the class for the object? ----
public Class getObjectClass()
{
Class retval = null;

if... 阅读全帖
r****n
发帖数: 1088
10
you can't get generic type in runtime because of the type erasure, so that
java can be backward compatible.
r****n
发帖数: 1088
11
you can't get generic type in runtime because of the type erasure, so that
java can be backward compatible.
g*****g
发帖数: 34805
12
来自主题: Java版 - 一个关于generics的问题
Since Java uses type erasure, generics is a compile time trick.
If it can't decide the type in compile time, it can't do instantiation.

template
the
o**2
发帖数: 168
F*******X
发帖数: 143
14
来自主题: Java版 - generics这样改对马?
水平有限,我不敢说对错,只是聊聊自己看法而已
" Class cls = null;// 我改成Class对吗?" 你是要变成:
Class cls = null; 对吗?
如果是,我感觉是有问题。按我的理解,Generic 是用来 define Class and method,
只在 compile time 的时候有用,在 run time 的时候是没用的。上面的 statement
是在 declare a reference ?应该是不能 compile 吧?
o***i
发帖数: 603
15
来自主题: Java版 - generics这样改对马?
没问题的。
java的generic和c++不一样
o***i
发帖数: 603
F*******X
发帖数: 143
17
来自主题: Java版 - generics这样改对马?
和我的猜想吻合了,“ Class cls = null; ”根据我的回
忆这种不是Generic,我没有看过这形式的,我认为是应该不能compile。但 “Class > cls = null;”能compile是因为这形式相当于“Class cls = null;" 其
他同学有不同看法吗?
d****i
发帖数: 4809
18
一般的普通的class,可以通过MyClass.class得到,但是如果有Generics的情况,由于
type erasure,就没法得到它的class,比如我想用List.class,就会报错,
但是有些class method只接受这样的input argument:
public void foo(Class class)
如果我想传入一个List的类的话,怎么办?没法用
foo(List.class)
d****i
发帖数: 4809
19
Thanks. This is a nice solution. I think it is similar to goodbug's solution
but it uses a generic List in the wrapper class.

wrapper
x****d
发帖数: 1766
20
来自主题: Java版 - 问个 Generic 的问题
1, too old, it is not updated for long time, you can redo it in generic if
your company used it a lot, but in some company that means get legal
department involved to review the licence, pain in the butt.
2, public T[] toArray(T[] a), but as you said, not simple as your code.
f*******n
发帖数: 12623
21
来自主题: Java版 - 如何造Array of Generic Type
You can't. T doesn't exist at runtime. It's an illusion. Just remove T and
ask yourself how to do it. If you cannot do it without T, then you cannot do
it with T either:
public class SpecialArray {
Object[] createSpecialArray()
{
return (Object[])Array.newInstance(???, 10);
// How to get T?
// You do not pass anything into this method
}
}
Your problem is that arrays in Java know their component type at runtime. If
you do new String[5], the object knows it's an... 阅读全帖
s******e
发帖数: 493
22
来自主题: Java版 - 如何造Array of Generic Type
(Class)((ParameterizedType)getClass() .
getGenericSuperclass()).getActualTypeArguments()[0];
but there is some limit on this approach. check with hibernate generic dao
implementation
W***o
发帖数: 6519
23
来自主题: Java版 - 如何造Array of Generic Type
我记得java不支持generic array啊
c*********w
发帖数: 65
24
来自主题: Java版 - 如何造Array of Generic Type
You can do it using option 1, option 2 is cleaner but requires changing of
your method api:
http://docs.oracle.com/javase/tutorial/extra/generics/literals.
m********7
发帖数: 1368
25
来自主题: Java版 - error: generic array creation
JAVA刚入门,请教一个低级的问题,如何 create a generic array? 如果比较复杂,
能否提供一个好用的reference,多谢!
public static > void sort(T[] a){
T[] tmp = new T[a.length]; <---error
sort(a,tmp, 0, a.length-1);
}
p********e
发帖数: 1
26
A 和 B 应该继承同一个Abstract class 或者是Interface,然后就可以用Generic了
A extends C {
}
B extends C {
}
Then
Comparator
vi
发帖数: 309
27
来自主题: Programming版 - JAVA generic programming 是怎么实现的?
JAVA generic programming (JDK 1.5) 是怎么实现的?与C++的机制有什么不同?谢谢!
f*****y
发帖数: 12
28
来自主题: Programming版 - JAVA generic programming 是怎么实现的?
I'm not familiar with Java, but this article might help:
http://java.sun.com/j2se/1.5/pdf/generics-tutorial.pdf

t**r
发帖数: 3428
29
现在还有人猛钻研c++模板编程,generic programming, 甚至meta-programming么
模板编程简单用用还可以
我现在工作中能用到一点点。不过也是属于组里大牛搭好了架子的 我不用太操心 呵呵
但是更深的东西。。再往里钻大家觉得有有意思么???
纯讨论 OPEN QUESTION。
l******d
发帖数: 530
30
来自主题: Programming版 - 用c怎么实现generic stack (转载)
【 以下文字转载自 JobHunting 讨论区 】
发信人: lwsOsgvd (lwsOsgvd), 信区: JobHunting
标 题: 用c怎么实现generic stack
发信站: BBS 未名空间站 (Tue Apr 24 16:42:43 2012, 美东)
用设计个stack,要求是The stack should be able to take as input a wide
variety of data types: it could range from byte sized to an n-byte sized
structure。
刚好在PIE书里面看到这个
typedef struct Element {
struct Element *next;
void *data;
} Element;
不知道算不算达到要求。
多谢!
d****n
发帖数: 1637
31
来自主题: Programming版 - 用c怎么实现generic stack (转载)
generic C 有两类,一类是 void *, 但是有转换消耗。
另一类是 C marco,但是难debug
对于你的要求,可变的size,当然要用C marco
///file gstack.c
#define _STACK_STRUCT(STACKNAME, DATATYPE) \
typedef struct STACKNAME { \
struct STACKNAME * next;\
DATATYPE value;\
}STACKNAME##_t;
#define __STACK_POP(STACKNAME, DATATYPE ) \
void pop_##STACKNAME( STACKNAME##_t *node ) \
{ \
;\
}
#define __STACK_PUSH(STACKNAME, DATATYPE ) \
void push_##STACKNAME( STACKNAME##_t *node ) \
{ \
... 阅读全帖
d****n
发帖数: 1637
32
来自主题: Programming版 - 用c怎么实现generic stack (转载)
DATATYPE can be anything , pointer or a complex data struct.
And there is not cast need in my Code.
Indeed, Type Cast DOES cost overhead. And if constantly doing that, codes
will become bitterly disgusting for debugging by programmers. For example,
the "undefined member" issues will happen alot when programmer forget the
original definition of the data type need to be converted.
Also, you already conclude yourself that "除了多打几个字". If comparing with
easiness of developing, more typing means more m... 阅读全帖
g****r
发帖数: 1589
33
来自主题: Programming版 - Java终于要支持primitive type的generic了
http://www.infoq.com/news/2014/12/Java10EnhancedGenerics?utm_so
2018年出品,不过还改不了type erasure,所以完全的generic支持还得再等
n****l
发帖数: 1739
34
来自主题: Programming版 - Java终于要支持primitive type的generic了
just curious, how many program errors are type related errors?
my guess is very few. most generic programmings are overkill.
Y**G
发帖数: 1089
35
来自主题: Programming版 - Go什么时候可能支持Generic?
今年有戏吗?没有Generic令人抓狂阿
a***n
发帖数: 623
36
来自主题: Programming版 - Go什么时候可能支持Generic?
短期内不会有generic,不过你看TiDB这么复杂的项目都用Go写出来了相信Go不会是一
门让你抓狂的语言。
n***a
发帖数: 222
37
来自主题: Programming版 - 求教一个java generics的小白问题
假设我有一个class Inspector
现在有人写了个command line tool叫做abcInspector, 这个class里面把type 给定死
了abc:
Inspector inspector = new Inspector<>();
...
我想要扩展这个abcInspector, 就是加一个option, 让用户可以传进来其他class
name比如def,然后inspector就会变成Inspector inspector。。。 请问该怎么
写?
直接用Class的变量会报错, 因为generics需要在compile time就决定class
p*******m
发帖数: 136
38
【 以下文字转载自 shopping 讨论区 】
发信人: playitsam (Play as time goes by. 追忆灌水的年华.), 信区: shopping
标 题: —个叫Generic!atr的病毒,死活杀不掉
发信站: BBS 未名空间站 (Tue Jan 1 02:29:24 2008)
大侠们给点建议吧
McAfee报告有这个
C:\ windows\ system32\Auto run .inf
但是去不掉
这文件好象
杀了以后又再生
q*****g
发帖数: 1568
39
一个小问题,我用dvipdf生成pdf文件的时候总是有这样一个warning:
dvips: warning: no config file for `generic'
当然这个不是什么大问题,但是每次都看见这样一个warning还是很烦。
不知道如何让dvipds/dvips default成用letter 大小?
谢谢。
q*****g
发帖数: 1568
40
【 以下文字转载自 Linux 讨论区 】
发信人: qiuxing (球星), 信区: Linux
标 题: Re: dvips: warning: no config file for `generic' (转载)
发信站: BBS 未名空间站 (Sat Aug 27 17:16:15 2005), 转信
Google了好久,没有发现任何直接的答案。倒是发现了一个新的问题,
好像Linux里头所有和打印相关的命令by default都用A4纸。可是在美
国一般打印机都用letter size。这个现在我也也不知道该怎么去改。
w***e
发帖数: 17
41
请教各位大人:
我的pc操作系统是XP,没有安装service pack 2。从前的防毒软件是瑞星2005,安装迅雷
后,上网速度变慢,后来又
安装了F-secure。结果,现在常常是开机一会儿后就跳出窗口说:Generic Host Process
for Win32 Services Error
需要关闭,接着就有三个问题:
1)不能连接internet
2) 音频文件无法使用,ms找不到我的声卡。
3)偶尔发生:工具栏/开始/my computer等无法使用。
这些问题在卸载了瑞星,迅雷和F-secure之后仍然存在。
请问这是病毒哩,还是软件冲突?有米有什么办法解决?
谢谢!
s*******e
发帖数: 9
42
Generic Host Process for Win32 Services has encountered a problem,blah,
blah,....
对于这个老问题了,我都一直忍过来了,每次把弹出的窗口关掉了事。
可是换了64 bit windows xp (x86) 之后,这个问题变得无法容忍了。每次打开my
computer (资源管理器)都需要2分钟以上的时间,然后弹出这个错误信息,然后再
等2分钟,然后my computer才打开了...
有人能救救我吗?
z****n
发帖数: 79
43
遗传算法(generic algorithm) 可以起什么用?我知道它可以用来找最短路径,还可以
做什么别的用呢? 比如,它可以用来预测一个将来的事件的概率,如下个月的销售额吗?
如果可以,那么什么时候用这个算法?它有什么局限呢?
c******d
发帖数: 71
44
Sorry to bother you. Can any topology expert here help me with the following.
I read the paper:
Decentralized pole assignment and product grassmannians, SIAM journal on
control and optimization, vol. 32, no 3, pp. 855-875, 1994.
I got a paragraph like this:
Let $\Sigma_{m,p}^n$ be the set of all m-input, p-output
systems of degree n. Recall that $\Sigma_{m,p}^n$ is a quasi-affine variety
of dimension $n(m+p)$. A subset $U$ of $\Sigma_{m,p}^n$ is said to be
generic if $U$ is open and dense in $\S
w*******s
发帖数: 23
45
来自主题: Pharmaceutical版 - Generic drug
国内应多做GENERIC DRUG. 其实我们在这里的经验可以回国做的.大家有什么建议?
A*****s
发帖数: 813
46
来自主题: Pharmaceutical版 - Generic drug
国内哪有几家不是做generic的
c****e
发帖数: 1464
47
来自主题: Pharmaceutical版 - Generic drug
什么是generic drug啊?
d******g
发帖数: 111
48
来自主题: Pharmaceutical版 - Generic drug
你是不是说国内药厂应该做generic drug打入欧美市场?其实我觉得现在技术以及fda
GMP认证只是一个方面,更欠缺的是政策法规和市场方面的人才,中国对欧美市场根本
不了解,这个方面中国比印度确实差很远。不过海正等几个药厂好像在努力吧,也在学
印度原料药-非专利药-专利药的国际化路线。
M**1
发帖数: 162
49
来自主题: Pharmaceutical版 - GENERIC NAME and BRAND NAME
What's the difference between GENERIC NAME and BRAND NAME? Why is a drug
given two names?
M**1
发帖数: 162
50
来自主题: Pharmaceutical版 - GENERIC NAME and BRAND NAME
So, the drug is called by brand name before the patent expiration, and by
generic name after the patent expiration?
首页 上页 1 2 3 4 5 6 7 8 9 10 下页 末页 (共10页)