infinite

How can I make an iterator that never ends?

百般思念 提交于 2019-12-08 17:06:37
问题 I was just wondering what the easiest way to iterate over a set indefinitely, i.e. when it reaches the end it next(); calls the first object. I'm assuming that this is not an already predefined function in Java, so just looking for the easiest way to implement this in Java. 回答1: There's a method in the excellent Google Collections library which does this: Set<String> names = ...; Iterable<String> infinite = Iterables.cycle(names); (I can't recommend the Google Collections library strongly

jQuery clone infinite times?

寵の児 提交于 2019-12-08 13:35:17
问题 The way jQuery's .clone() seems to work, once you insert a cloned object somewhere, you cannot insert it again another time without re-cloning the original object. For example, if you do this: var cloned = $('#elem1').clone(); $('#elem2').after(cloned); $('#elem2').after(cloned); Only one copy of elem1 will get copied and the second after call would have done nothing. Is there a way to not "clear the clipboard" after using a cloned object? Right now I am making do by cloning the object again

Value-equals and circular references: how to resolve infinite recursion?

Deadly 提交于 2019-12-07 01:12:03
问题 I have some classes that contain several fields. I need to compare them by value, i.e. two instances of a class are equal if their fields contain the same data. I have overridden the GetHashCode and Equals methods for that. It can happen that these classes contain circular references. Example: We want to model institutions (like government, sports clubs, whatever). An institution has a name. A Club is an institution that has a name and a list of members. Each member is a Person that has a

Firebase: Google OAuth Infinite Redirects

妖精的绣舞 提交于 2019-12-06 12:40:11
问题 I'm fairly new to Firebase. I'm trying to hook up Google OAuth to my Firebase instance. I set everything up and got the client ID and client secrete. I added localhost to the whitelist in the Firebase dashboard. I then used the Firebase example below: <html> <head> <script src="https://cdn.firebase.com/js/client/2.0.4/firebase.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script> </head> <body> <script> var ref = new Firebase("https://<firebase

Making the diamond square fractal algorithm infinite

一世执手 提交于 2019-12-06 03:01:41
问题 I'm trying to generate an infinite map, as such. I'm doing this in Python, and I can't get the noise libraries to correctly work (they don't seem to ever find my VS2010, and doing it in raw Python would be way too slow). As such, I'm trying to use the Diamond-Square Algorithm. Would it be possible, in some way, to make this technically infinite? If not, should I just go back to attempting to get one of the Python noise bindings to work? 回答1: This can be done. Divide up your landscape into

Rare infinite loop in code, don't want to wait for it to happen again

可紊 提交于 2019-12-05 21:26:00
Ok, so I've got a genetic algorithm running in netbeans, and its been running for like 5 hours and seems to have entered an infinite loop. Is there any way that I can attach a debugger to it? or at least get some clue as to where it is in the code? I'd rather not sit around for another 5 hours while I wait for it to happen again. A simple way to get some basic information from your running program is to run jstack on it, it will print stack traces of all threads in your code. Do that several times and you should have a good idea what is wrong. Use jps to find out the id of your JVM like and

iPhone and iPad end of scrolling

末鹿安然 提交于 2019-12-05 09:36:52
I'm making some jQuery cross-browser gallery with infinite scroll i works great but on iPhone (i suppose also on iPad) instead equal values i have some disproportion values don't match ($(window).scrollTop() == ($(document).height() - $(window).height()) i just want to reach the end of scrolling on that , after that i could invoke AJAX script, also have to keep in mind that values changing after two fingers wipe zoom. Dan Jenns You need to account for the 60px URL text field on iPhone . Try this: ($(window).scrollTop() + 60 == ($(document).height() - $(window).height()) Marco Ramires var

VB.NET - It keep replacing itself

空扰寡人 提交于 2019-12-05 07:00:35
问题 I have in a text file lines of this format: word1|word2|word3 anotherword1|anotherword2 I'm trying to split each word one by one per every line of that file and once program detect if the richtextbox has one of these words will replace that word with the unsplitted line. Example: From word1 to word1|word2|word3 Here is what I have so far: Private Sub Button1_Click_1(sender As Object, e As EventArgs) Handles Button1.Click For Each line As String In File.ReadLines("C:\text.txt") Dim input As

Is equality testing possible between two infinite data structure in Haskell?

纵饮孤独 提交于 2019-12-05 04:45:00
In a project I'm working on, data of a certain type may sometimes contain themselves in it. For example, data Example = Apple Int | Pear Int Example a = Pear 10 a b = Pear 10 b As a programmer I know that a and b are equal, but when I actually test equality between them it would infinite loop because their values need to be evaluated for comparison. Is there any other way to do equality testing between data like these? Or is there a way to avoid problems like these? In general: no. This sort of equality testing reduces to the halting problem. One way to see this is that we could express the

Passing variable through URL with angular js

。_饼干妹妹 提交于 2019-12-05 03:31:25
I am using angular to make an e-commerce, and I'm setting an infinite scroll to the products list page. Everything worked fine, but I want to use the URL to set the page, so the user can access an specific page through URL. how do I set a variable like "pageNumber" in the URL with angular? like "www.page.com/page/2/"(I want to get the number 2 and pass it to the store controller) Here's the code I have now (function() { var app = angular.module('concurseirosUnidos', ['store-directives', 'ngRoute']); app.config(function($routeProvider, $locationProvider){ $locationProvider.html5Mode(true);