这篇文章(http://blogs.msdn.com/b/brada/archive/2005/01/18/355755.aspx)说的IEnumerable<T>是Contra-variant.然而,类型T是共变体,因为它是out参数.那么在什么情况下IEnumerable<T>Contra-variant?
希望我不要混淆!谢谢你的答案提前!
我有一个非常简单的UIScrollView例子,根本不做它应该做的事情.不确定它是API的错误还是我的代码中的错误.
基本上,我有一个UIViewController与UIScrollView它的观点.当我将它添加到UIWindow并更改iPad的方向时,我会注销UIScrollViews尺寸,这是错误的(?)报告.
这是我的UIViewController实现:
@implementation CustomViewController
- (void)loadView {
scrollView = [[[UIScrollView alloc] init] autorelease];
scrollView.delegate = self;
scrollView.backgroundColor = [UIColor redColor];
self.view = scrollView;
}
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
CGSize rect = scrollView.frame.size;
NSLog(@"will rotate w%f h%f", rect.width, rect.height);
}
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
CGSize rect = scrollView.frame.size;
NSLog(@"will animate rotation w%f h%f", rect.width, rect.height);
}
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
CGSize rect = scrollView.frame.size;
NSLog(@"did rotate w%f h%f", rect.width, …Run Code Online (Sandbox Code Playgroud) 可能重复:
反向字典查找 - Python
如果我有一个名为ref的字典如下
ref = {}
ref["abc"] = "def"
Run Code Online (Sandbox Code Playgroud)
我可以从"abc"获得"def"
def mapper(from):
return ref[from]
Run Code Online (Sandbox Code Playgroud)
但是,我如何才能从"def"变为"abc"?
def revmapper(to):
??????
Run Code Online (Sandbox Code Playgroud) 以下是我尝试使用热切的加载集合返回的实体示例.
混音 - >曲目(收藏) - >标签(收藏)
我需要返回一个带有急切加载的曲目和标签的混音的分页列表,而不需要通过使用Future <>()函数为曲目+标签运行多个查询来进行相对简单的分页.
因为需要对这些数据进行分页...如何恢复所有数据,以便NHibernate在显示数据时不会出现N + 1问题.
保罗
当我使用弹出窗口显示时,我希望能够模糊或调暗背景popup.showAtLocation,并在popup.dismiss调用时将背景解开/调暗.
我曾尝试应用布局PARAMS FLAG_BLUR_BEHIND和FLAG_DIM_BEHIND我的活动,但这似乎只是一旦我的应用程序开始模糊和朦胧的背景.
如何使用弹出框进行模糊/调光?
我有一个有趣的问题,在我的一种基于传递的编译器中出现了.每个传递都不知道其他传递,并且在命令模式链之后,一个公共对象沿着链传递.
传递的对象是对文件的引用.
现在,在其中一个阶段中,人们可能希望关联大量数据,例如该文件的SHA512哈希,这需要合理的时间来计算.但是,由于该块数据仅用于该特定情况,因此我不希望所有文件引用都需要为该SHA512保留空间.但是,我也不希望其他传递必须一遍又一遍地重新计算SHA512哈希.例如,某人可能只接受与给定SHA512列表匹配的文件,但是当文件引用到达链的末尾时,或者他们想要两者或者...... .etc时,他们不希望打印该值.
我需要的是某种容器,它只包含给定类型中的一种.如果容器不包含该类型,则需要创建该类型的实例并以某种方式存储它.它基本上是一个字典,其类型是用来查找的东西.
这是我到目前为止所获得的,相关的位是FileData::Get<t>方法:
class FileData;
// Cache entry interface
struct FileDataCacheEntry
{
virtual void Initalize(FileData&)
{
}
virtual ~FileDataCacheEntry()
{
}
};
// Cache itself
class FileData
{
struct Entry
{
std::size_t identifier;
FileDataCacheEntry * data;
Entry(FileDataCacheEntry *dataToStore, std::size_t id)
: data(dataToStore), identifier(id)
{
}
std::size_t GetIdentifier() const
{
return identifier;
}
void DeleteData()
{
delete data;
}
};
WindowsApi::ReferenceCounter refCount;
std::wstring fileName_;
std::vector<Entry> cache;
public:
FileData(const std::wstring& fileName) : fileName_(fileName)
{
}
~FileData()
{ …Run Code Online (Sandbox Code Playgroud) 这经常发生在我身上.例如,现在我将调试器停在方法的断点处...并且它根本不显示任何变量值.其他时候,它显示一些,但不显示其他.
谁能解释一下?
我了解到Java不是100%OOP语言,这是因为数据类型不是对象.但据我来说,int是一个类型的Integer,并Integer属于Number和Number属于Object.所以java是100%的OOP语言.我对么?
我正在尝试使用Zend和PHPUnit为控制器编写单元测试
在代码中我从php:// input获取数据
$req = new Zend_Controller_Request_Http();
$data = $req->getRawBody();
Run Code Online (Sandbox Code Playgroud)
当我测试真实的应用程序时,我的代码工作正常,但除非我可以提供数据作为原始http帖子,否则$ data将始终为空.getRawBody()方法基本上调用file_get_contents('php:// input'),但是如何覆盖它以便将测试数据提供给我的应用程序.
我想编写一个函数printAll(),它只接受那些实现Iterable实现的元素,这样我就可以迭代它们并打印元素.我怎么做?
generics ×2
java ×2
android ×1
c# ×1
c++ ×1
collections ×1
covariance ×1
debugging ×1
dictionary ×1
ienumerable ×1
ios ×1
ipad ×1
iterable ×1
nhibernate ×1
orientation ×1
pagination ×1
php ×1
phpunit ×1
popupwindow ×1
python ×1
types ×1
uiscrollview ×1
unit-testing ×1
xcode ×1