• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Pair类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中gnu.lists.Pair的典型用法代码示例。如果您正苦于以下问题:Java Pair类的具体用法?Java Pair怎么用?Java Pair使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Pair类属于gnu.lists包,在下文中一共展示了Pair类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: rewrite

import gnu.lists.Pair; //导入依赖的package包/类
@Override
public Expression rewrite (Object obj, final Translator tr) {
    if (Translator.listLength(obj) != 1)
        return tr.syntaxError("'scan' requires a single argument");
    Translator.ScanContext savedScanContext = tr.getScanContext();
    if (savedScanContext == null)
        tr.error('e', "'scan' not in a '...'- context");
    try {
        tr.setScanContext(null);
        Expression scanExp = tr.rewrite_car((Pair) obj, false);
        Declaration paramDecl =
            savedScanContext.getLambda().addParameter(null);
        savedScanContext.addSeqExpression(scanExp);
        return new ReferenceExp(paramDecl);
    } finally {
        tr.setScanContext(savedScanContext);
    }
}
 
开发者ID:spurious,项目名称:kawa-mirror,代码行数:19,代码来源:Scan.java


示例2: evaluate

import gnu.lists.Pair; //导入依赖的package包/类
public Object evaluate(Object clauses, Translator tr) {
    while (clauses instanceof Pair) {
        Pair pclauses = (Pair) clauses;
        Object clause = pclauses.getCar();
        clauses = pclauses.getCdr();
        if (! (clause instanceof Pair))
            tr.errorWithPosition("cond-expand clauses is not a list",
                                 pclauses);
        Pair pclause = (Pair) clause;
        Object test = Translator.stripSyntax(pclause.getCar());
        if ((test == elseSymbol && clauses == LList.Empty)
            || evaluateConditionCar(pclause, tr))
            return pclause.getCdr();
    }
    tr.errorIfNonEmpty(clauses);
    return LList.Empty;
}
 
开发者ID:spurious,项目名称:kawa-mirror,代码行数:18,代码来源:IfFeature.java


示例3: createMessageForGetAndEvalScripts

import gnu.lists.Pair; //导入依赖的package包/类
private String createMessageForGetAndEvalScripts(LList urlsOrScripts) {
	if (urlsOrScripts.isEmpty()) {
		return "";
	}
	Pair p = (Pair) urlsOrScripts;
	String e = (String) p.getCar();

	if (e.startsWith("http:") || e.startsWith("/")) {
		return String
				.format("$.getScript($.inArray('%s', loadedScripts)==-1?'%s':null)"
						+ ".always(function(script, textStatus) {"
						+ "%s" + "});"
						+ "if($.inArray('%s', loadedScripts)==-1){loadedScripts.push('%s');}",
						e, e,
						createMessageForGetAndEvalScripts((LList) p.getCdr()), e, e);
	} else {
		return e + System.lineSeparator()
				+ createMessageForGetAndEvalScripts((LList) p.getCdr());
	}

}
 
开发者ID:MAGCruise,项目名称:magcruise-core,代码行数:22,代码来源:Player.java


示例4: deepCopyLList

import gnu.lists.Pair; //导入依赖的package包/类
private static Serializable deepCopyLList(LList obj) {
	Object rest = obj;
	List<Serializable> l = new ArrayList<>();
	while (true) {
		if (rest == LList.Empty)
			break;
		if (rest instanceof Pair) {
			Pair pair = (Pair) rest;
			l.add(deepCopy(pair.getCar()));
			rest = pair.getCdr();
		} else {
			l.add(deepCopy(rest));
			break;
		}
	}
	return (Serializable) l;
}
 
开发者ID:MAGCruise,项目名称:magcruise-core,代码行数:18,代码来源:LiteralUtils.java


示例5: llistToLiteral

import gnu.lists.Pair; //导入依赖的package包/类
private static String llistToLiteral(ToExpressionStyle style, LList obj) {
	if (obj == null) {
		return "#!null";
	}
	Object rest = obj;
	StringBuffer sbuf = new StringBuffer(100);
	sbuf.append("(list ");
	for (int i = 0;;) {
		if (rest == LList.Empty)
			break;
		if (i > 0)
			sbuf.append(' ');
		if (rest instanceof Pair) {
			Pair pair = (Pair) rest;
			sbuf.append(toLiteral(style, pair.getCar()));
			rest = pair.getCdr();
		} else {
			sbuf.append(". ");
			sbuf.append(toLiteral(style, rest));
			break;
		}
		i++;
	}
	sbuf.append(')');
	return sbuf.toString();
}
 
开发者ID:MAGCruise,项目名称:magcruise-core,代码行数:27,代码来源:LiteralUtils.java


示例6: proc

import gnu.lists.Pair; //导入依赖的package包/类
private static void proc(LList args, Map<Keyword, Object> argsMap) {
	if (!(args instanceof Pair)) {
		return;
	}
	Pair p = (Pair) args;
	Object car = p.getCar();
	LList cdr = ((LList) p.getCdr());
	if (car instanceof Keyword) {
		argsMap.put((Keyword) car, ((Pair) cdr).getCar());
	} else {
		argsMap.put(Keyword.make("rest"), new ArrayList<Object>(Arrays.asList(args.toArray())));
		return;
	}

	proc((LList) ((Pair) cdr).getCdr(), argsMap);
}
 
开发者ID:MAGCruise,项目名称:magcruise-core,代码行数:17,代码来源:LiteralUtils.java


示例7: procAttrsForInsert

import gnu.lists.Pair; //导入依赖的package包/类
protected void procAttrsForInsert(ActorObject target, int roundnum, List<String> attrNames,
		List<Object> vals) {
	RoundHistory r = target.getHistory().getRoundHistory(roundnum);
	for (Pair pair : target.getAttributeAndFieldNamePairs()) {
		Symbol key = (Symbol) pair.getCdr();
		attrNames.add(key.toString());
		Serializable val = r.get(key);
		if (IntNum.class.isAssignableFrom(val.getClass())) {
			vals.add(((IntNum) val).intValue());
		} else if (DFloNum.class.isAssignableFrom(val.getClass())) {
			vals.add(((DFloNum) val).doubleValue());
		} else if (Number.class.isAssignableFrom(val.getClass())) {
			vals.add(val);
		} else {
			vals.add(val.toString());
		}
	}

}
 
开发者ID:MAGCruise,项目名称:magcruise-core,代码行数:20,代码来源:DynamicTable.java


示例8: toArray

import gnu.lists.Pair; //导入依赖的package包/类
/**
 * Return this YailList as an array.
 */
@Override
public Object[] toArray() {
  if (cdr instanceof Pair) {
    return ((Pair) cdr).toArray();
  } else if (cdr instanceof LList) {
    return ((LList) cdr).toArray();
  } else {
    throw new YailRuntimeError("YailList cannot be represented as an array", "YailList Error.");
  }
}
 
开发者ID:mit-cml,项目名称:appinventor-extensions,代码行数:14,代码来源:YailList.java


示例9: toString

import gnu.lists.Pair; //导入依赖的package包/类
/**
 * Return a String representation of this YailList.
 */
@Override
public String toString() {
  if (cdr instanceof Pair) {
    return ((Pair) cdr).toString();
  } else if (cdr instanceof LList) {
    return ((LList) cdr).toString();
  } else {
    throw new RuntimeException("YailList cannot be represented as a String");
  }
}
 
开发者ID:mit-cml,项目名称:appinventor-extensions,代码行数:14,代码来源:YailList.java


示例10: readVector

import gnu.lists.Pair; //导入依赖的package包/类
public static FVector readVector(LispReader lexer, InPort port, int count, char close, int sharingIndex)
   throws java.io.IOException, SyntaxException
 {
   char saveReadState = ' ';
   if (port instanceof InPort)
     {	
saveReadState = ((InPort) port).readState;
((InPort) port).readState = close == ']' ? '[' : '(';
     }
   int startLine = port.getLineNumber();
   int startColumn = port.getColumnNumber()-1;
    try
      {
        FVector result = new FVector();
        lexer.bindSharedObject(sharingIndex, result);

        ReadTable rtable = ReadTable.getCurrent();
        Pair head = new Pair(null, LList.Empty);
        Pair last = head;
 for (;;)
   {
     int ch = lexer.read();
     if (ch < 0)
       lexer.eofError("unexpected EOF in vector starting here",
		      startLine + 1, startColumn);
     if (ch == close)
       break;
            last = lexer.readValuesAndAppend(ch, rtable, last);
   }
        result.replaceAll(((LList) head.getCdr()).toArray());
        result.setReadOnly();
 return result;

      }
    finally
      {
 if (port instanceof InPort)
   ((InPort) port).readState = saveReadState;
      }
 }
 
开发者ID:spurious,项目名称:kawa-mirror,代码行数:41,代码来源:ReaderVector.java


示例11: setMenuHelper

import gnu.lists.Pair; //导入依赖的package包/类
/**
 * Heavily inspired from gnu.jemacs.swing.SwingMenu
 */
private void setMenuHelper(Menu parent, LList list)
{
  
  for (Iterator iter = list.iterator(); iter.hasNext();)
  {
    Object o = iter.next();
    try
    {
      if (o == null) 
      {
        continue;
      }
      else if (o instanceof Pair)
      {
        CharSequence menuName = (CharSequence) ((Pair) o).getCar();
        MenuItem menuItem = SwtHelper.newMenuItem(parent, SWT.CASCADE, menuName.toString(), null);
        Menu subMenu = SwtHelper.newMenu(menuItem);
        setMenuHelper(subMenu, (LList) ((Pair) o).getCdr());
        SwtHelper.setMenu(menuItem, subMenu);
      }
      else if (o instanceof FVector) 
      {
        CharSequence menuItemName = (CharSequence) ((FVector) o).get(0);
        Object command = ((FVector) o).get(1);
        SwtHelper.newMenuItem(parent, SWT.DROP_DOWN, menuItemName.toString(), new MenuCommandHandler(command));
      }
      else if (o instanceof CharSequence) 
      {
       SwtHelper.newMenuItem(parent, SWT.SEPARATOR, null, null); 
      }
    }
    catch (Exception e) 
    {
      System.err.println("SwtFrame.setMenu - problem with " + o);
    }
  }
}
 
开发者ID:spurious,项目名称:kawa-mirror,代码行数:41,代码来源:SwtFrame.java


示例12: rewrite

import gnu.lists.Pair; //导入依赖的package包/类
public Expression rewrite (Object obj, Translator tr)
{
  if (! (obj instanceof Pair))
    return tr.syntaxError("invalid syntax for unwind-protect");
  Pair pair = (Pair) obj;
  return new TryExp(tr.rewrite(pair.getCar()), tr.rewrite_body(pair.getCdr()));
}
 
开发者ID:spurious,项目名称:kawa-mirror,代码行数:8,代码来源:UnwindProtect.java


示例13: readVector

import gnu.lists.Pair; //导入依赖的package包/类
public static FVector readVector(LispReader lexer, InPort port, int count, char close, int sharingIndex)
   throws java.io.IOException, SyntaxException
 {
   char saveReadState = ' ';
   if (port instanceof InPort)
     {	
saveReadState = ((InPort) port).readState;
((InPort) port).readState = close == ']' ? '[' : '(';
     }
   int startLine = port.getLineNumber();
   int startColumn = port.getColumnNumber()-1;
    try
      {
        ConstVector result = new ConstVector();
        lexer.bindSharedObject(sharingIndex, result);

        ReadTable rtable = ReadTable.getCurrent();
        Pair head = new Pair(null, LList.Empty);
        Pair last = head;
 for (;;)
   {
     int ch = lexer.read();
     if (ch < 0)
       lexer.eofError("unexpected EOF in vector starting here",
		      startLine + 1, startColumn);
     if (ch == close)
       break;
            last = lexer.readValuesAndAppend(ch, rtable, last);
   }
        result.setDataBackDoor(((LList) head.getCdr()).toArray());
 return result;

      }
    finally
      {
 if (port instanceof InPort)
   ((InPort) port).readState = saveReadState;
      }
 }
 
开发者ID:maoueh,项目名称:kawa-fork,代码行数:40,代码来源:ReaderVector.java


示例14: setMenuHelper

import gnu.lists.Pair; //导入依赖的package包/类
/**
 * Heavily inspired from gnu.jemacs.swing.SwingMenu
 */
private void setMenuHelper(Menu parent, LList list)
{
  
  for (Iterator iter = list.iterator(); iter.hasNext();)
  {
    Object o = iter.next();
    try
    {
      if (o == null) 
      {
        continue;
      }
      else if (o instanceof Pair)
      {
        CharSequence menuName = (CharSequence) ((Pair) o).car;
        MenuItem menuItem = SwtHelper.newMenuItem(parent, SWT.CASCADE, menuName.toString(), null);
        Menu subMenu = SwtHelper.newMenu(menuItem);
        setMenuHelper(subMenu, (LList) ((Pair) o).cdr);
        SwtHelper.setMenu(menuItem, subMenu);
      }
      else if (o instanceof FVector) 
      {
        CharSequence menuItemName = (CharSequence) ((FVector) o).get(0);
        Object command = ((FVector) o).get(1);
        SwtHelper.newMenuItem(parent, SWT.DROP_DOWN, menuItemName.toString(), new MenuCommandHandler(command));
      }
      else if (o instanceof CharSequence) 
      {
       SwtHelper.newMenuItem(parent, SWT.SEPARATOR, null, null); 
      }
    }
    catch (Exception e) 
    {
      System.err.println("SwtFrame.setMenu - problem with " + o);
    }
  }
}
 
开发者ID:mit-cml,项目名称:ai2-kawa,代码行数:41,代码来源:SwtFrame.java


示例15: readVector

import gnu.lists.Pair; //导入依赖的package包/类
public static FVector readVector(LispReader lexer, LineBufferedReader port, int count, char close, int sharingIndex)
   throws java.io.IOException, SyntaxException
 {
   char saveReadState = ' ';
   if (port instanceof InPort)
     {	
saveReadState = ((InPort) port).readState;
((InPort) port).readState = close == ']' ? '[' : '(';
     }
   int startLine = port.getLineNumber();
   int startColumn = port.getColumnNumber()-1;
    try
      {
        ConstVector result = new ConstVector();
        lexer.bindSharedObject(sharingIndex, result);

        ReadTable rtable = ReadTable.getCurrent();
        Pair head = new Pair(null, LList.Empty);
        Pair last = head;
 for (;;)
   {
     int ch = lexer.read();
     if (ch < 0)
       lexer.eofError("unexpected EOF in vector starting here",
		      startLine + 1, startColumn);
     if (ch == close)
       break;
            last = lexer.readValuesAndAppend(ch, rtable, last);
   }
        result.setDataBackDoor(((LList) head.getCdr()).toArray());
 return result;

      }
    finally
      {
 if (port instanceof InPort)
   ((InPort) port).readState = saveReadState;
      }
 }
 
开发者ID:alain91,项目名称:kawa,代码行数:40,代码来源:ReaderVector.java


示例16: getAttributeAndFieldNamePairs

import gnu.lists.Pair; //导入依赖的package包/类
public List<Pair> getAttributeAndFieldNamePairs(Symbol... keys) {
	List<Pair> pairs = new ArrayList<>();
	getHistoricalFields().forEach((HistoricalAnnotatedField af) -> {
		if (keys.length == 0 || Arrays.asList(keys).contains(af.getFieldNameAsSymbol())) {
			if (af.isVisible()) {
				pairs.add(new Pair(af.getAnnotationName(), af.getFieldNameAsSymbol()));
			}
		}
	});
	return pairs;
}
 
开发者ID:MAGCruise,项目名称:magcruise-core,代码行数:12,代码来源:HistoricalObject.java


示例17: getPlayers

import gnu.lists.Pair; //导入依赖的package包/类
public LList getPlayers(ActorName... names) {
	List<Player> result = new ArrayList<>();
	for (ActorName name : names) {
		result.add(players.get(name));
	}
	return Pair.makeList(result);
}
 
开发者ID:MAGCruise,项目名称:magcruise-core,代码行数:8,代码来源:Context.java


示例18: tabulate

import gnu.lists.Pair; //导入依赖的package包/类
public String tabulate(int from, int to, Symbol... keys) {
	if (history.size() == 0) {
		return "";
	}

	Serializable[] targets = keys;
	List<Pair> pairs = new ArrayList<>();

	for (Serializable target : targets) {
		pairs.add(new Pair(target, target));
	}
	return tabulate(from, to, pairs.toArray(new Pair[0]));
}
 
开发者ID:MAGCruise,项目名称:magcruise-core,代码行数:14,代码来源:History.java


示例19: DefScene

import gnu.lists.Pair; //导入依赖的package包/类
public DefScene(Symbol name, Pair behaviors) {
	this.name = name;
	for (Object db : behaviors) {
		this.defBehaviors.add((DefBehavior) db);
	}

}
 
开发者ID:MAGCruise,项目名称:magcruise-core,代码行数:8,代码来源:DefScene.java


示例20: drainTo

import gnu.lists.Pair; //导入依赖的package包/类
private static void drainTo(KeyValueTable result, LList args) {
	if (args.isEmpty()) {
		return;
	}
	Pair pair = (Pair) args;
	LList arg = (LList) pair.getCar();

	Map<Keyword, Object> argsMap = LiteralUtils.createArgsMap(arg);
	Symbol name = (Symbol) argsMap.get(Keyword.make("name"));
	Object defaultVal = argsMap.get(Keyword.make("default"));
	LList round = (LList) argsMap.get(Keyword.make("round"));
	LList queue = (LList) argsMap.get(Keyword.make("queue"));
	LList roundQueues = (LList) argsMap.get(Keyword.make("round-queues"));
	if (round != null) {
		result.putValueOfEachRound(name.toString(), round);
	}
	if (roundQueues != null) {
		List<Queue<?>> qs = new CopyOnWriteArrayList<>();
		for (Object o : new ArrayList<>(roundQueues)) {
			qs.add(new ConcurrentLinkedQueue<>((List<?>) o));
		}
		result.putQueuesOfEachRound(name.toString(), qs);
	}

	if (queue != null) {
		result.putQueue(name.toString(), queue);
	}
	if (defaultVal != null) {
		result.putDefaultValue(name.toString(), defaultVal);
	}

	drainTo(result, (LList) pair.getCdr());

}
 
开发者ID:MAGCruise,项目名称:magcruise-core,代码行数:35,代码来源:KeyValueTableFactory.java



注:本文中的gnu.lists.Pair类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Functions类代码示例发布时间:2022-05-22
下一篇:
Java OWLOntologyFormat类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap