overlap

Subtract Overlaps Between Two Ranges Without Sets

百般思念 提交于 2019-11-30 04:00:06
NO SETS! I can't use Sets because: The ranges will be too long. They will take up too much memory The creation of the sets themselves will take too long. Using only the endpoints of the of the ranges, is there an optimal way to subtract two lists of ranges? Example: r1 = (1, 1000), (1100, 1200) r2 = (30, 50), (60, 200), (1150, 1300) r1 - r2 = (1, 29), (51, 59), (201, 1000), (1100, 1149) Other info: r2 does not have to overlap r1 r1 and r2 will not have pairs that overlap other pairs. For instance, r1 will not have both (0,30) and (10, 25) Thanks. The interval package may provide all that you

First view above / overlapping second in LinearLayout

我的梦境 提交于 2019-11-30 02:45:13
问题 Is it possible to show the first view in a LinearLayout overlapping the second? I would like to layout my views like so: <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_alignParentRight="true" > <TextView android:id="@+id/firstTextView" android:layout_width="wrap_content" android:layout_height="wrapContent" /> <TextView android:id="@+id/secondTextView" android:layout_width="wrap_content" android:layout

How can you detect if two regular expressions overlap in the strings they can match?

十年热恋 提交于 2019-11-30 02:02:40
I have a container of regular expressions. I'd like to analyze them to determine if it's possible to generate a string that matches more than 1 of them. Short of writing my own regex engine with this use case in mind, is there an easy way in C++ or Python to solve this problem? There's no easy way. As long as your regular expressions use only standard features (Perl lets you embed arbitrary code in matching, I think), you can produce from each one a nondeterministic finite-state automaton (NFA) that compactly encodes all the strings that the RE matches. Given any pair of NFA, it's decidable

How to prevent edges in graphviz to overlap each other

瘦欲@ 提交于 2019-11-29 22:48:35
I have a graph I've created in graphviz, but the problem is that edges overlap each other (I have 5-7 nodes in each row), so it is hard to tell for each node which are the nodes it connects. How can I make the edges not to overlap each other? Have them cross each other is OK. I'm assuming you have a directed graph which you layout with dot. I don't think there's a magic switch to prevent overlapping edges. Graphviz tries to do that out of the box. Some suggestions that may help, depending on the graph: edge concentrators (concentrate=true): Merge multiple edges with a common endpoint into

R Time periods overlapping

感情迁移 提交于 2019-11-29 22:03:27
问题 With "lubridate" package in R, I can find out if two time periods overlapped. but Is there an efficient way to compute for how many days they overlapped. (for instance how many days a women smoked while pregnant. the pregnancy period and smoking period may overlap totally, partially or not at all) Here is an example with three women: preg_start<-as.Date(c("2011-01-01","2012-01-01","2013-01-01")) preg_end<-preg_start+270 # end after 9 months smoke_start<-as.Date(c("2011-02-01","2012-08-01",

How to find elements that are common to all lists in a nested list?

烈酒焚心 提交于 2019-11-29 16:08:07
I have a large nested list and each list within the nested list contains a list of numbers that are formatted as floats. However every individual list in the nested list is the same except for a few exceptions. I want to extract the numbers that are common to all of the lists in the nested list. A simple example of my problem is shown below: nested_list = [[1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0,11.0,12.0,13.0,14.0,15.0], [2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0,11.0,12.0,13.0,14.0], [1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0,11.0,12.0,13.0,14.0], [2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0,11.0,12.0

How to overlap UITableViewCells?

馋奶兔 提交于 2019-11-29 12:49:24
问题 If you look at the screenshot you will notice that each UITableViewCell are 20% overlapped from top portion to the upper tableview cell. Is there any way we can overlap cells ? 回答1: I never tried it, but this kind of logic will work. Remember, you won't get any touch in the overlapped area. 1) Add your subview to cell.contentView , make sure subview height is greater than rowHeight of your tableView. float overlapHeight = 10.0; subView.frame = CGRectMake(0.0, -10.0, your_subview_width,

How to jitter lines in ggplot2

筅森魡賤 提交于 2019-11-29 12:11:27
Say I have the following data and plot: require(reshape2) require(ggplot2) data <- data.frame(id=seq(1,9,1), var1=c(10,3,5,7,8,9,4,6,5), var2=c(9,3,5,7,8,9,4,6,5)) data_graph <- melt(data, id="id") ggplot(data=data_graph, aes(y=value, x=id, group=variable, col=variable)) + geom_line(size=2) + geom_point() + geom_text(aes(label=value), size=5, hjust=-.6, vjust=1.5) For almost the entirety of both lines, there is overlap. Is there any way to somehow jitter the lines so that they are close to each other, but don't overlap. Or to do something to know that there are two lines? There is a function

Finding elements that do not overlap between two vectors

不羁岁月 提交于 2019-11-29 11:57:07
问题 I'm trying to identify elements which are not included in the other vector. For instance in two vectors I have list.a <- c("James", "Mary", "Jack", "Sonia", "Michelle", "Vincent") list.b <- c("James", "Sonia", "Vincent") is there a way to verify which people do not overlap? In the example, I would want to get the vector result that contains Mary, Jack, and Michelle. Any suggestions will help! 回答1: Yes, there is a way: setdiff(list.a, list.b) # [1] "Mary" "Jack" "Michelle" 回答2: I think it

JavaScript Separating Axis Theorem

放肆的年华 提交于 2019-11-29 10:59:50
问题 I'm trying to wrap my head around using the Separating Axis Theorem in JavaScript to detect two squares colliding (one rotated, one not). As hard as I try, I can't figure out what this would look like in JavaScript, nor can I find any JavaScript examples. Please help, an explanation with plain numbers or JavaScript code would be most useful. Update: After researching lots of geometry and math theories I've decided to roll out a simplified SAT implementation in a GitHub repo. You can find a