Questions tagged [peek]

Refers to a non-destructive operation performed on sequential, collection-like data structures that have the notion of "top element" or "next element", such as stacks, queues and streams. The `peek` operation returns the value of the "top" (or "next") element without "consuming" that element, i.e. without removing that element from the data structure.

163 questions
0
votes
2 answers

Thumbnail Toolbar Button

Today I have another specific question about a new feature in windows 7 called the thumbnail toolbar or the Aero Peek Toolbar if some might like to call it that way. I have been able to create a new set of toolbar buttons for my application each…
Zaid Amir
  • 4,727
  • 6
  • 52
  • 101
0
votes
1 answer

C 'recv' with MSG_PEEK doesn't return -1

I'm writing a C function to check if a socket connection from client is available. I use 'recv' function with MSG_PEEK not to alter the input buffer. However, when the socket connection is closed by client, 'recv' is supposed to return -1, but it…
jondinham
  • 8,271
  • 17
  • 80
  • 137
-1
votes
2 answers

How can I use st.peek() function in java if I pushed a pair of elements?

I created a user defined class pair to add two elements in stack. But how can I use peek function of the stack? I want to access the "element" of pair class using peek. import java.util.*; public class Example { public static class pair{ …
-1
votes
1 answer

Why does cin.peek() == '\n' work for '+' and '-', but not for '*', '/', and '^'?

I'm doing a calculator in replit. Why does my cin.peek() == '\n' work when I enter + and - but it doesn't work when I enter *, /, or ^? #include #include #include #include using namespace std; float…
-1
votes
1 answer

How to do peek operation in queue in C?

#include #include #include #define max 100 int enqueue(); int dequeue(); int peek(); void display(); int main() { char name[max][80], data[80]; int front, rear, value; int ch; front = rear =…
anna
  • 41
  • 5
-1
votes
1 answer

How Go buffer read data from io.Reader?

I'm learning for Go bufio package, and confused by a code snippet below: 1 s1 := strings.NewReader(strings.Repeat("a", 16) + strings.Repeat("b", 16)) 2 r := bufio.NewReaderSize(s1, 16) 3 b, _ := r.Peek(3) 4 fmt.Printf("%q\n", b) 5 …
-1
votes
1 answer

vb.net - r.peek()>=0 line = r.readline()

I am using vb.net to read a text file and see if a record matched, and to pick out that record and write it to excel. However with the peek loop it reads the file until the end of it. I have 2 peek loop - the outer peek loop looks for the item, the…
Johnseito
  • 315
  • 1
  • 9
  • 24
-1
votes
1 answer

Type 'MainVC' does not conform to protocol 'UIViewControllerPreviewingDelegate'

I don't know what I'm doing wrong, but my class MainVC can't conform to the protocol UIViewControllerPreviewingDelegate. I've searched all over the internet but couldn't find a single person who had the same issue. This is my class: class MainVC:…
-1
votes
4 answers

Removing the last item from a queue in C#

We have the Enqueue and Dequeue methods to work on a queue in C#. But is there a way we can remove the last item in the queue? Dequeue actually removes the item from the top.
Slick Guy
  • 35
  • 2
  • 7
-1
votes
2 answers

Queue unexpectedly puts last element in the front when I call poll()

I have the following code. I'm trying to do a breadth first search of a tree that I created call HabitItem. Here is queue traveral import java.io.File; import java.util.*; import java.util.concurrent.PriorityBlockingQueue; public static void…
Cameron
  • 2,805
  • 3
  • 31
  • 45
-1
votes
2 answers

istream operator >> not recognising '\n' character

I am basically reading a .txt file and storing values. For example: Student- Mark Tennis It will store Mark into memory as the studentName. Now...If it is just Student- Tennis Then it will work fine and produce an error. However, if the file…
Sam Thers
  • 67
  • 3
  • 12
-1
votes
1 answer

How to read a stack.peek in order to put it in an if statement C#

I am trying to create a menu system and i am storing the menus in stacks once they have already been visited. Im trying to use Stack.Peek() to basically say: if menuName = menuStack.Peek, then continue. menus have a drawRectangle, sprite, and…
user1801067
  • 133
  • 2
  • 12
-2
votes
2 answers

How to remove and print every item in an IntStack object until it is empty?

I am having trouble figuring out how to remove and print every item in an IntStack object until it is empty. Would I need to use an if statement? I know the basics of stacks, for example: Suppose s refers to an IntStack object. If I wanted to add…
1 2 3
10
11