Это должно быть O (1) с L.pop (-1), а O (n) с L.pop (0)
см. следующий пример:
from timeit import timeit
if __name__ == "__main__":
L = range(100000)
print timeit("L.pop(0)", setup="from __main__ import L", number=10000)
L = range(100000)
print timeit("L.pop(-1)", setup="from __main__ import L", number=10000)
>>> 0.291752411828
>>> 0.00161794329896
в Java 1.5 +:
"hello|world".split(Pattern.quote("|"));
Выйдите из этого с помощью \\ :
"hello|world".split("\\|");
"hello|world".split("\\\\|"); --> {"hello", "world"}
Первый набор "\\"
дает только \ в качестве разделителя. Следовательно, для выхода из трубы необходимо 2 комплекта.
I have this problem a lot (encoding a regex into a Java String
), so I have bookmarked the regex tool at fileformat.info; it has a nifty function where it will show you the Java String
representation of a regex after you test it.