bar

Create Hash Value on a List?

匿名 (未验证) 提交于 2019-12-03 08:42:37
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a List<MyRichObject> with 50 instances in it. Each of the instances has 1 or 2 unique properties, but in a way they are all unique because there is only one at position in the list, etc. I would like to come up with a unique way to "hash" this List so it is unique from all of the other Lists. Is there a smart way to do that in .NET 4? The purpose is to create a kind of "monniker" for the Lists so they can be dumped into a queue and found later based on their unique value. Thanks. 回答1: TL;DR public static int GetSequenceHashCode<T>

Progress bar while copying files with Java

匿名 (未验证) 提交于 2019-12-03 08:41:19
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm sure this question has been asked before, but none of the answers I found will work very well with my existing code. I'm posting this question in case there's a way to do it without completely redoing what I have so far. The idea is to display a very basic progress bar while copying files and directories from one drive to another. I have a class called BasicCopy that is designed to copy the contents of the Pictures, Documents, videos, and Music folders (standard on Windows machines) to folders of the same names within a backup directory

Java generics: Illegal forward reference

匿名 (未验证) 提交于 2019-12-03 08:41:19
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Given a generic interface interface Foo<A, B> { } I want to write an implementation that requires A to be a subclass of B. So I want to do class Bar<A, B super A> implements Foo<A, B> { } // --> Syntax error or class Bar<A extends B, B> implements Foo<A, B> { } // --> illegal forward reference But the only solution that seems to work is this: class Bar<B, A extends B> implements Foo<A, B> { } which is kind of ugly, because it reverses the order of the generic parameters. Are there any solutions or workarounds to this problem? 回答1: Since this

Reset action bar after using SearchView

匿名 (未验证) 提交于 2019-12-03 08:36:05
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm using SearchView widget to enable searching in my app. After the initial click on the search icon, the SearchView widget expands into the search field and the "back" arrow is shown next to the application icon. If I click the application icon the action bar reverts to the initial state (no "back" arrow) and the SearchView reverts back to icon. Now the problem: after the search is executed the action bar doesn't change, the only way to revert is to click the application icon or phone's "back" arrow. Not good since I want the action bar go

How to implement a ZIP JOIN in T-SQL?

匿名 (未验证) 提交于 2019-12-03 08:36:05
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: Let say I have table #Foo: Id Color -- ---- 1 Red 2 Green 3 Blue 4 NULL And table #Bar: Value ----- 1 2.5 I would like to create table Result using simple statement to get: Id Color Value -- ---- ----- 1 Red 1 2 Green 2.5 3 Blue NULL 4 NULL NULL What I have invented so far is: WITH cte1 AS ( SELECT [ Id ], [ Color ], ROW_NUMBER () OVER ( ORDER BY [ Id ]) AS 'No' FROM #Foo ), cte2 AS ( SELECT [ Value ], ROW_NUMBER () OVER ( ORDER BY [ Value ]) AS 'No' FROM #Bar ) SELECT [ Id ], [ Color ], [ Value ] FROM cte1 c1 FULL OUTER JOIN cte2

Height of screen without status bar, actionBar and tabs

匿名 (未验证) 提交于 2019-12-03 08:35:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a ListView that I want each row to fill a third of the available screen. I have the status bar visible, and then an actionBar with slidingTabs beneath. I'm doing the current calculation like this: height = context.getResources().getDisplayMetrics().heightPixels; if (context.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) { actionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data,context.getResources().getDisplayMetrics()); Log.d("actionBarHeigth", actionBarHeight.toString()); } And setting the views height

How to create two classes in C++ which use each other as data?

匿名 (未验证) 提交于 2019-12-03 08:33:39
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I'm looking to create two classes, each of which contains an object of the other class type. How can I do this? If I can't do this, is there a work-around, like having each class contain a pointer to the other class type? Thanks! Here's what I have: File: bar.h #ifndef BAR_H #define BAR_H #include "foo.h" class bar { public : foo getFoo (); protected : foo f ; }; #endif File: foo.h #ifndef FOO_H #define FOO_H #include "bar.h" class foo { public : bar getBar (); protected : bar b ; }; #endif File: main.cpp #include "foo.h" #include

Do scala constructor parameters default to private val?

匿名 (未验证) 提交于 2019-12-03 08:33:39
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have been trying: class Foo(bar: Int) vs: class Foo(private val bar: Int) and they seem to behave the same although I couldn't find anywhere saying that (bar: Int) expands to (private val bar: Int) so my question is, are these identical/similar? On a side note, I have been trying to use -Xprint:typer on these code pieces and they produce the same code except for an extra line in the second one. How do I read that extra line? .. class Foo extends scala.AnyRef { private[this] val bar: Int = _; def (bar: Int): this.Foo = { Foo.super. (); () }

XPath axis, get all following nodes until

匿名 (未验证) 提交于 2019-12-03 08:33:39
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have the following example of HTML: Foo bar lorem ipsum etc Bar baz dum dum dum poopfiddles I'm looking to extract all paragraphs following the 'Foo bar' header, until I reach the 'Bar baz' header (the text for the 'Bar baz' header is unknown, so unfortunately I can't use the answer provided by bougyman). Now I can of course using something like //h2[text()='Foo bar']/following::p but that of course will grab all paragraphs following this header. So I have the option to traverse the nodeset and push paragraphs into an Array until the text

Why can template&lt;T&gt; but not template&lt;&gt; be defined outside of a namespace block?

匿名 (未验证) 提交于 2019-12-03 08:33:39
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: Here is some code which does not compile. namespace ns { class foo { template < typename T > int bar ( T *); }; } template < typename T > int ns :: foo :: bar ( T *) // this is OK { return 0 ; } template <> int ns :: foo :: bar <int> ( int *) // this is an error { return 1 ; } The error is: "specialisation of ‘template int ns::foo::bar(T*)’ in different namespace [-fpermissive] from definition of ‘template int ns::foo::bar(T*)" Here is a version which does compile: namespace ns { class foo { template < typename T > int bar ( T *);