peek Questions
3
Solved
What is the official way of peeking in a python heap as created by the heapq libs? Right now I have
def heappeak(heap):
smallest = heappop(heap)
heappush(heap, smallest)
return smallest
which...
2
Solved
I have a server net.Conn, and I'd like to peek into it before reading out bytes, to check if it's a plain text protocol the client is trying to use, or SSL/TLS.
Checking http://golang.org/pkg/net/,...
Immensity asked 4/10, 2014 at 20:20
19
Solved
I can't figure out how to look ahead one element in a Python generator. As soon as I look it's gone.
Here is what I mean:
gen = iter([1,2,3])
next_value = gen.next() # okay, I looked forward and se...
4
Solved
Let's say I have an iterator:
function* someIterator () {
yield 1;
yield 2;
yield 3;
}
let iter = someIterator();
... that I look at the next element to be iterated:
let next = iter.next()...
Axis asked 11/4, 2020 at 21:58
10
Solved
I'm reading up about Java streams and discovering new things as I go along. One of the new things I found was the peek() function. Almost everything I've read on peek says it should be used to debu...
Mancini asked 10/11, 2015 at 17:12
5
Solved
Currently, there isn't a NetworkStream.Peek method in C#. What is the best way of implementing such a method which functions just like NetworkStream.ReadByte except that the returned byte is not ac...
Contaminate asked 4/2, 2010 at 1:20
7
Solved
I want to get the next item in queue but I don't want to dequeue it. Is it possible in Python's queue.PriorityQueue? From the docs, I don't see how can it be done
Forequarter asked 15/2, 2012 at 4:34
7
Solved
I am aware of the specific function in golang from the bufio package.
func (b *Reader) Peek(n int) ([]byte, error)
Peek returns the next n bytes without advancing the reader. The bytes
stop b...
Son asked 1/12, 2012 at 15:29
4
Solved
C++ has the following function to receive bytes from socket, it can check for number of bytes available with the MSG_PEEK flag. With MSG_PEEK, the returned value of 'recv' is the number of bytes av...
1
Solved
I am trying to do something simple. In a slice of u8, I want to find occurrence of two characters "\r\n". However, I cannot convert that slice into String using from_utf8 because parts of slice aft...
Mindexpanding asked 4/6, 2020 at 4:23
6
Solved
With Java Iterators, I have used the hasNext method to determine whether an iteration has more elements (without consuming an element) -- thus, hasNext is like a "Peek" method.
My question: is the...
Conjurer asked 13/8, 2009 at 16:13
2
Solved
According to the doc of .try_iter() method of the Receiver end of a Rust std::mpsc::channel, I understand that this iterator either yield "None":
when there is no data in the channel
or when the ...
Iguana asked 22/12, 2019 at 19:50
8
Solved
I have a blocking queue of objects.
I want to write a thread that blocks till there is a object on the queue. Similar to the functionality provided by BlockingQueue.take().
However, since I do no...
Pruter asked 18/11, 2009 at 23:11
7
Solved
From all the sources I've read, they say - the difference between peek and pop is that peek doesn't remove the top value.
In the provided example from my lecture notes, apparently they do the same ...
2
Solved
I am in the progress of learning through Java 8 lambda expressions and would like to ask about the following piece of Java code relating to the peek method in the function interface that I have com...
7
Solved
While looking around for a while I found quite a few discussions on how to figure out the number of lines in a file.
For example these three:
c# how do I count lines in a textfile
Determine the n...
Stockman asked 9/1, 2013 at 17:45
8
Solved
Is there a way to check if in BufferedReader object is something to read? Something like C++ cin.peek(). Thanks.
Swanskin asked 25/3, 2010 at 17:0
2
Solved
A LinkedList has convenient peek, pop, ... methods.
Unfortunately, I need a thread-safe LinkedList. So, my first idea was to wrap it as follows:
List<Object> list = Collections.synchronized...
Trovillion asked 20/11, 2015 at 16:46
3
Solved
I'm trying to receive a UDP message using sockets in c++.
I'm sending the size of the message in the header, so I can know how much memory should I allocate, so I try to peek at the beggining of t...
1
Solved
I'm using Python 3, and the peek() method for buffered file I/O doesn't seem to work as documented. For example, the following code illustrates the problem -- it prints 8192 as the length of the by...
6
Solved
As in the title. Why does the Stack class need a method to return a reference of the top object? I've always been told, that methods suggest there's some computing involved and that simple ob...
3
Solved
Is it possible to Peek at the value of a C# Stack variable layers below the surface? In my example, I need to Peek at the value one below. I could Peek to record the value into a temporary variable...
2
Solved
Lets say I have an outer while loop to read each character and output it to console. I also want to flag a word if it is found and by using the peek method I can find the first instance of a word. ...
1
Solved
I would like to call sys.stdin.readlines() without removing anything from stdin. I am using Python2.7 on Linux.
For example, what I want is:
x = sys.stdin.readlines()
y = sys.stdin.readlines()
...
Dollar asked 17/7, 2013 at 22:51
4
Here's my scenario. I have a TCP client that is talking to the server. Both the server and the client are running on local machine (Windows).
The dialog goes something like:
Client sends data to...
1 Next >
© 2022 - 2024 — McMap. All rights reserved.