我想生成一个如下所示的迷宫:

也就是说,它由一个方向上的路径组成,然后连接起来.我已经找了一个算法来生成这样的迷宫而没有成功.
具体来说,我不想要像这样的迷宫:
因为它不会只在一个方向"运行".
此外,如果这个迷宫的解决方案需要玩家"回溯" - 即不是一直向上移动,那将是很好的.
问题:我有一个方法可以从解析的ArrayList创建一个列表.我设法在GUI中显示列表,没有滚动条.但是,我有问题设置它只显示ArrayList的大小.意思是,如果大小为6,则显示的列表中应该只有6行.下面是我正在使用的代码.我尝试设置visibleRowCount如下,但它不起作用.我尝试打印出结果,它显示了更改.
private void createSuggestionList(ArrayList<String> str) {
int visibleRowCount = str.size();
System.out.println("visibleRowCount " + visibleRowCount);
listForSuggestion = new JList(str.toArray());
listForSuggestion.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
listForSuggestion.setSelectedIndex(0);
listForSuggestion.setVisibleRowCount(visibleRowCount);
System.out.println(listForSuggestion.getVisibleRowCount());
listScrollPane = new JScrollPane(listForSuggestion);
MouseListener mouseListener = new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent mouseEvent) {
JList theList = (JList) mouseEvent.getSource();
if (mouseEvent.getClickCount() == 2) {
int index = theList.locationToIndex(mouseEvent.getPoint());
if (index >= 0) {
Object o = theList.getModel().getElementAt(index);
System.out.println("Double-clicked on: " + o.toString());
}
}
}
};
listForSuggestion.addMouseListener(mouseListener);
textPane.add(listScrollPane);
repaint();
}
Run Code Online (Sandbox Code Playgroud)
总结一下:我希望JList显示与解析的ArrayList的大小一样多的行,而不需要滚动条 …
我有一个模块读取进程的StandardError.一切都很好,但我想做一些不同的事情.我不知道如何像本机方式重定向stdin:
app1.exe -someargs | app2.exe -someargs
app2在其标准输入中读取app1的所有标准输出.
我有这个LINQ查询
dbContext.Customers.Where(c => c.AssetTag == assetTag).Count();
Run Code Online (Sandbox Code Playgroud)
要么
(from c in dbContext.Customers
where c.AssetTag == assetTag
select c).Count();
Run Code Online (Sandbox Code Playgroud)
生成的SQL是
SELECT
[GroupBy1].[A1] AS [C1]
FROM ( SELECT
COUNT(1) AS [A1]
FROM [dbo].[Customer] AS [Extent1]
WHERE (([Extent1].[AssetTag] = @p__linq__0) AND ( NOT ([Extent1].[AssetTag] IS NULL OR @p__linq__0 IS NULL))) OR (([Extent1].[AssetTag] IS NULL) AND (@p__linq__0 IS NULL))
) AS [GroupBy1]
Run Code Online (Sandbox Code Playgroud)
那么为什么LINQ会为一个简单的where语句生成如此复杂的SQL呢?
当使用lambdas时,通常是在TPL上,我会因缩进而迷失...是否有一些最佳实践来格式化?例如,请使用以下代码:
Task t1 = factory.StartNew(() =>
{
DoSomething();
}
.ContinueWith((t2) =>
{
DoSomethingWhenComplete();
}, TaskContinuationOptions.OnlyOnRanToCompletion)
).ContinueWith((t3) =>
{
DoSomethingOnError();
}, TaskContinuationOptions.OnlyOnFaulted);
Run Code Online (Sandbox Code Playgroud)
我正在挖掘Polymer 1.0元素,我对计算属性有点好奇.
例如,在paper-drawer-panel.html中,
<dom-module id="paper-drawer-panel" …>
…
<div id="main" style$="[[_computeDrawerStyle(drawerWidth)]]">
…
</div>
…
</dom-module>
<script>
Polymer({
is: 'paper-drawer-panel',
…
_computeDrawerStyle: function(drawerWidth) {
return 'width:' + drawerWidth + ';';
},
…
</script>
Run Code Online (Sandbox Code Playgroud)
drawerWidth是一个属性paper-drawer-panel,为什么将它显式包含在计算属性的参数中如此重要?
是
[[_computeDrawerStyle()]]
…
_computeDrawerStyle: function () {
return 'width:' + this.drawerWidth + ';';
}
Run Code Online (Sandbox Code Playgroud)
这是不好的做法吗?
我熟悉大括号的绑定,比如{{variable}}Polymer 0.5.
但是,在Polymer的发布版本的示例和代码片段中,我开始注意到带有方括号的绑定,例如[[variable]].
难道{{variable}}现在的意思是不同的东西,或者是相同的,[[variable]]仅仅是一个加法?绑定到聚合物[[variable]]和{{variable}}聚合物之间有什么区别?
这可能是一个非常基本的问题,但它仍然让我感到困惑(谷歌无法帮助);-)如何将通用对象作为参数传递给函数?
例如,我有一个班级 CoolGeneric<T>
现在我需要一个方法DoSomethingWithAGeneric(CoolGeneric g).在这里,编译器继续抱怨具体的类型参数是必要的.但该方法应该适用于各种类型的参数!
我怎样才能做到这一点?谢谢!
在使用 AES 加密和解密时,我正面临着本线程中提到的完全相同的问题。
crypto.js:202
var ret = this._handle.final(); ^ 错误:错误:0606506D:数字信封例程:EVP_DecryptFinal_ex: Decipher.Cipher.final (crypto.js:202:26)
处错误(本机)的最终块长度错误
这些是我的加密和解密功能:
var config = {
cryptkey: crypto.createHash('sha256').update('Nixnogen').digest(),
iv: "a2xhcgAAAAAAAAAA"
};
function encryptText(text){
console.log(config.cryptkey);
var cipher = crypto.createCipheriv('aes-256-cbc', config.cryptkey, config.iv);
var crypted = cipher.update(text,'utf8','binary');
crypted += cipher.final('binary');
crypted = new Buffer(crypted, 'binary').toString('base64');
return crypted;
}
function decryptText(text){
console.log(config.cryptkey);
if (text === null || typeof text === 'undefined' || text === '') {return text;};
text = new Buffer(text, 'base64').toString('binary');
var decipher = crypto.createDecipheriv('aes-256-cbc', config.cryptkey, config.iv);
var dec …Run Code Online (Sandbox Code Playgroud) 我添加了以下两个模型视图类:
public class AssetCount
{
public int CustomerCount { get; set; }
public int DataCenterCount { get; set; }
public int FirewallCount { get; set; }
public int RouterCount { get; set; }
public int VirtualMachineCount { get; set; }
public int ServerCount { get; set; }
public int StorageDeviceCount { get; set; }
public int RackCount { get; set; }
public int SwitchCount { get; set; }
public int CustomCount { get; set; }
}
public class SystemInformation
{ …Run Code Online (Sandbox Code Playgroud) 我正在开发一个简单的应用程序,该应用程序每60秒检查一次数据库。我曾经System.Threading.TimerCallback这样做,但是,当我运行该应用程序时,它只会滴答一次。
这是代码:
private void Form1_Load(object sender, EventArgs e)
{
// Create the delegate for the Timer type.
System.Threading.TimerCallback timeCB = new System.Threading.TimerCallback(d);
// Establish timer settings.
System.Threading.Timer t = new System.Threading.Timer(
timeCB, // The TimerCallback delegate object.
null, // Any info to pass into the called method (null for no info).
0, // Amount of time to wait before starting (in milliseconds).
1000); // Interval of time between calls (in milliseconds).
}
void m(object o)
{
System.Media.SystemSounds.Hand.Play();
SReminderEntities …Run Code Online (Sandbox Code Playgroud) c# ×6
polymer ×2
polymer-1.0 ×2
.net ×1
aes ×1
algorithm ×1
asp.net ×1
c#-2.0 ×1
coding-style ×1
cryptography ×1
data-binding ×1
encryption ×1
generics ×1
java ×1
jlist ×1
lambda ×1
linq ×1
maze ×1
mongoose ×1
node.js ×1
sql ×1
swing ×1
timer ×1
winforms ×1