range

Data structure to build and lookup set of integer ranges

放肆的年华 提交于 2019-11-28 04:10:08
问题 I have a set of uint32 integers, there may be millions of items in the set. 50-70% of them are consecutive, but in input stream they appear in unpredictable order. I need to: Compress this set into ranges to achieve space efficient representation. Already implemented this using trivial algorithm, since ranges computed only once speed is not important here. After this transformation number of resulting ranges is typically within 5 000-10 000, many of them are single-item, of course. Test

R: need finite 'ylim' values in function

╄→гoц情女王★ 提交于 2019-11-28 04:02:33
问题 I'd like to plot the data in data.frame xy for each group (defined by ID ). When a year before 1946 is in a group, plot 2 should be executed. When the years are between 1946 and 2014, plot1 should be executed. My problem: This works fine without NA values, but as I have data gaps I rely on NAs to define these data gaps. This is why I get an error: error in plot.window(need finite 'ylim' values) . I tried to put finite=T in plot1 at the y-axis but this gives a subscript out of bounds error. Is

How to change/view the ephemeral port range on Windows machines?

江枫思渺然 提交于 2019-11-28 03:50:54
问题 In Linux I can view or change the ephemeral port range using the /proc/sys/net/ipv4/ip_local_port_range file. How can I view or change the ephemeral port range on a Windows machine? 回答1: http://www.ncftp.com/ncftpd/doc/misc/ephemeral_ports.html#Windows says: As of Windows Vista and Windows Server 2008, Windows now uses a large range (49152-65535) by default, according to Microsoft Knowledgebase Article 929851. That same article also shows how you can change the range if desired, but the

Is there a need for range(len(a))?

房东的猫 提交于 2019-11-28 03:01:49
One frequently finds expressions of this type in python questions on SO. Either for just accessing all items of the iterable for i in range(len(a)): print(a[i]) Which is just a clumbersome way of writing: for e in a: print(e) Or for assigning to elements of the iterable: for i in range(len(a)): a[i] = a[i] * 2 Which should be the same as: for i, e in enumerate(a): a[i] = e * 2 # Or if it isn't too expensive to create a new iterable a = [e * 2 for e in a] Or for filtering over the indices: for i in range(len(a)): if i % 2 == 1: continue print(a[i]) Which could be expressed like this: for e in a

Can I hint the optimizer by giving the range of an integer?

余生颓废 提交于 2019-11-28 02:37:34
I am using an int type to store a value. By the semantics of the program, the value always varies in a very small range (0 - 36), and int (not a char ) is used only because of the CPU efficiency. It seems like many special arithmetical optimizations can be performed on such a small range of integers. Many function calls on those integers might be optimized into a small set of "magical" operations, and some functions may even be optimized into table look-ups. So, is it possible to tell the compiler that this int is always in that small range, and is it possible for the compiler to do those

How to implement Haskell's splitEvery in Swift?

£可爱£侵袭症+ 提交于 2019-11-28 02:07:52
PROBLEM let x = (0..<10).splitEvery( 3 ) XCTAssertEqual( x, [(0...2),(3...5),(6...8),(9)], "implementation broken" ) COMMENTS I am running into problems calculating number of elements in the Range, etc... extension Range { func splitEvery( nInEach: Int ) -> [Range] { let n = self.endIndex - self.startIndex // ERROR - cannot invoke '-' with an argument list of type (T,T) } } The values in a range are of ForwardIndexType , so you can only advance() them, or compute the distance() , but the subtraction - is not defined. The advance amount has to be of the corresponding type T.Distance . So this

2 Column Mysql Date Range Search in PHP

做~自己de王妃 提交于 2019-11-28 01:57:35
问题 MySQL column > sdate, edate ( its 2 column). sdate is start date for project starting and edate is end date for project ending. so i need to make search between them.. <strong>Search</strong><br /> <form method="post" action="search.php"> Start Report Date : <input type="text" name="sdate" /> End Report Date : <input type="text" name="edate" /> <input type="submit" name="Submit" value="Search" /> </form> This is example data in mysql sdate Project Name edate 22 December 2008 project 1 23

Hotel Room Rates for different seasons

故事扮演 提交于 2019-11-28 01:54:16
问题 I have a database (MySQL) with a table containing date ranges (as startdate and enddate) and a rate field. The date range implies different seasons (low, high etc.). The scenario is such that a person checks in the hotel and his duration of stay is in two seasons. A sample data is like below: SeasonName SartDate EndDate Rate Low 01-01-2007 30-04-2007 100.00 High 01-05-2007 31-08-2007 150.00 Peak 01-09-2007 31-12-2007 200.00 The client's Check In Date is 29-04-2007 and Check Out Date is 03-05

Excel VBA worksheet.names vs worksheet.range

◇◆丶佛笑我妖孽 提交于 2019-11-28 01:32:59
I have created a defined name/range on a worksheet called bob , pointing to a single cell. There are a number of other name/ranges set up on this worksheet, which I didn't create. All the number/ranges work perfectly except for mine. I should be able to refer to the contents of this cell by using either of the following statements: (worksheet object).Names("bob").RefersToRange.Value (worksheet object).Range("bob").Value However, only the second statement, referring to the Range works for some reason. The first one can't find the name in the Names list. My questions are: What is the difference,

Limiting user input to a range in Python

我们两清 提交于 2019-11-28 01:22:51
问题 In the code below you'll see it asking for a 'shift' value. My problem is that I want to limit the input to 1 through 26. For char in sentence: if char in validLetters or char in space: #checks for newString += char #useable characters shift = input("Please enter your shift (1 - 26) : ")#choose a shift resulta = [] for ch in newString: x = ord(ch) #determines placement in ASCII code x = x+shift #applies the shift from the Cipher resulta.append(chr(x if 97 <= x <= 122 else 96+x%122) if ch != \