Example #1
0
panel_above(const PANEL * pan)
{
  T((T_CALLED("panel_above(%p)"), pan));
  if (!pan)
    {
      /* if top and bottom are equal, we have no or only the pseudo panel;
         if not, we return the panel above the pseudo panel */
      returnPanel(EMPTY_STACK()? (PANEL *) 0 : _nc_bottom_panel->above);
    }
  else
    returnPanel(pan->above);
}
Example #2
0
PANEL*
panel_below(const PANEL *pan)
{
  if(!pan)
    {
      /* if top and bottom are equal, we have no or only the pseudo panel */
      return(EMPTY_STACK() ? (PANEL*)0 : _nc_top_panel);
    }
  else
    {
      /* we must not return the pseudo panel */
      return(Is_Pseudo(pan->below) ? (PANEL*) 0 : pan->below);
    }
}
Example #3
0
void printEnv (size_t step, int n, AQueue aQ, AStack *Events, FILE *out) {
	fprintf(out, "%zu\n", step);
	
	printQ(aQ, print, out);
	fprintf(out, "\n");
	
	for (int i = 0; i < n; ++i) {
		if (!EMPTY_STACK(Events[i])) {
			fprintf(out, "%d: ", i);
			printS(Events[i], print, out);
			fprintf(out, "\n");
		}
	}
	
	fprintf(out, "\n");
}
int kthSmallest(struct TreeNode *root,int k){
	int counter = 0;
	struct TreeNode *current = root;
	while (current || !EMPTY_STACK()){
		while (current) {
			PUSH_STACK(current);
			current = current->left;
		}
		current = TOP_STACK();
		counter++;
		if (counter == k)
			return current->val; 
		POP_STACK();
		current = current->right;
	}
	return -1;
}
Example #5
0
//just pops that stack and add elements to queue
int event (size_t evNo, AQueue aQ, AStack *Events) {
	TProcess *ae = malloc(sizeof(TProcess));
	if (!ae) return 0;
	
	int check = 0;
	while (!EMPTY_STACK(Events[evNo])) {
		pop(Events[evNo], ae);
		check = intrQ(aQ, ae, cmp);
		if (check == 0) {
			free(ae);
			return 0;
		}
	}
	
	free(ae);
	return 1;
}
Example #6
0
ceiling_panel(SCREEN * sp)
{
  T((T_CALLED("ceiling_panel(%p)"), sp));
  if (sp)
    {
      struct panelhook *ph = NCURSES_SP_NAME(_nc_panelhook) (sp);

      /* if top and bottom are equal, we have no or only the pseudo panel */
      returnPanel(EMPTY_STACK()? (PANEL *) 0 : _nc_top_panel);
    }
  else
    {
      if (0 == CURRENT_SCREEN)
	returnPanel(0);
      else
	returnPanel(ceiling_panel(CURRENT_SCREEN));
    }
}
Example #7
0
panel_above(const PANEL * pan)
{
  PANEL *result;

  T((T_CALLED("panel_above(%p)"), (const void *)pan));
  if (pan)
    result = pan->above;
  else
    {
#if NCURSES_SP_FUNCS
      result = ground_panel(CURRENT_SCREEN);
#else
      /* if top and bottom are equal, we have no or only the pseudo panel;
         if not, we return the panel above the pseudo panel */
      result = EMPTY_STACK()? (PANEL *) 0 : _nc_bottom_panel->above;
#endif
    }
  returnPanel(result);
}
Example #8
0
panel_below(const PANEL * pan)
{
  PANEL *result;

  T((T_CALLED("panel_below(%p)"), (const void *)pan));
  if (pan)
    {
      GetHook(pan);
      /* we must not return the pseudo panel */
      result = Is_Pseudo(pan->below) ? (PANEL *) 0 : pan->below;
    }
  else
    {
#if NCURSES_SP_FUNCS
      result = ceiling_panel(CURRENT_SCREEN);
#else
      /* if top and bottom are equal, we have no or only the pseudo panel */
      result = EMPTY_STACK()? (PANEL *) 0 : _nc_top_panel;
#endif
    }
  returnPanel(result);
}