本文整理汇总了C#中IPersistentMap类的典型用法代码示例。如果您正苦于以下问题:C# IPersistentMap类的具体用法?C# IPersistentMap怎么用?C# IPersistentMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IPersistentMap类属于命名空间,在下文中一共展示了IPersistentMap类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: NewExpr
public NewExpr(Type type, List<HostArg> args, IPersistentMap spanMap)
{
_args = args;
_type = type;
_spanMap = spanMap;
_ctor = ComputeCtor();
}
开发者ID:roffster,项目名称:clojure-clr,代码行数:7,代码来源:NewExpr.cs
示例2: Create
public static IPersistentList Create(IList list, IPersistentMap metadata)
{
if (list == null || list.Count == 0)
return EmptyList.Instance;
return new ListObject(list, 0, metadata);
}
开发者ID:ajlopez,项目名称:AjSharpure,代码行数:7,代码来源:ListObject.cs
示例3: Keyword
private Keyword(string ns, string name, IPersistentMap metadata)
: base(metadata)
{
this.ns = ns;
this.name = name;
this.hash = Utilities.CombineHash(name.GetHashCode(), Utilities.Hash(ns));
}
开发者ID:ajlopez,项目名称:AjSharpure,代码行数:7,代码来源:Keyword.cs
示例4: Parse
public static Expr Parse(ParserContext pcon, IPersistentMap form)
{
ParserContext pconToUse = pcon.EvEx();
bool constant = true;
IPersistentVector keyvals = PersistentVector.EMPTY;
for (ISeq s = RT.seq(form); s != null; s = s.next())
{
IMapEntry e = (IMapEntry)s.first();
Expr k = Compiler.Analyze(pconToUse, e.key());
Expr v = Compiler.Analyze(pconToUse, e.val());
keyvals = (IPersistentVector)keyvals.cons(k);
keyvals = (IPersistentVector)keyvals.cons(v);
if (!(k is LiteralExpr && v is LiteralExpr))
constant = false;
}
Expr ret = new MapExpr(keyvals);
if (form is IObj && ((IObj)form).meta() != null)
return Compiler.OptionallyGenerateMetaInit(pcon, form, ret);
else if (constant)
{
IPersistentMap m = PersistentHashMap.EMPTY;
for (int i = 0; i < keyvals.length(); i += 2)
m = m.assoc(((LiteralExpr)keyvals.nth(i)).Val, ((LiteralExpr)keyvals.nth(i + 1)).Val);
return new ConstantExpr(m);
}
else
return ret;
}
开发者ID:christianblunden,项目名称:clojure-clr,代码行数:29,代码来源:MapExpr.cs
示例5: PersistentList
internal PersistentList(object first, IPersistentList rest, int count, IPersistentMap metadata)
: base(metadata)
{
this.first = first;
this.rest = rest;
this.count = count;
}
开发者ID:ajlopez,项目名称:AjSharpure,代码行数:7,代码来源:PersistentList.cs
示例6: CreateForMetaAlter
internal static IFn CreateForMetaAlter(IPersistentMap meta)
{
AFnImpl fn = new AFnImpl();
fn._fn0 = () => { return meta; };
fn._fn1 = (object x) => { return meta; };
return fn;
}
开发者ID:richhickey,项目名称:clojure-clr,代码行数:7,代码来源:DummyFn.cs
示例7: IfExpr
public IfExpr( IPersistentMap sourceSpan, Expr testExpr, Expr thenExpr, Expr elseExpr)
{
_sourceSpan = sourceSpan;
_testExpr = testExpr;
_thenExpr = thenExpr;
_elseExpr = elseExpr;
}
开发者ID:JvJ,项目名称:clojure-clr,代码行数:7,代码来源:IfExpr.cs
示例8: withMeta
/// <summary>
/// Create a copy with new metadata.
/// </summary>
/// <param name="meta">The new metadata.</param>
/// <returns>A copy of the object with new metadata attached.</returns>
public override IObj withMeta(IPersistentMap meta)
{
// Java doesn't make the identity test: return new Cons(meta, _first, _rest);
return (meta == _meta)
? this
: new Cons(meta, _first, _more);
}
开发者ID:TerabyteX,项目名称:clojure-clr,代码行数:12,代码来源:Cons.cs
示例9: WithMetadata
public override IObject WithMetadata(IPersistentMap metadata)
{
if (this.Metadata == metadata)
return this;
return new Cons(this.first, this.rest, metadata);
}
开发者ID:ajlopez,项目名称:AjSharpure,代码行数:7,代码来源:Cons.cs
示例10: Parse
public static Expr Parse(ParserContext pcon, IPersistentMap form)
{
ParserContext pconToUse = pcon.EvEx();
bool constant = true;
IPersistentVector keyvals = PersistentVector.EMPTY;
for (ISeq s = RT.seq(form); s != null; s = s.next())
{
IMapEntry e = (IMapEntry)s.first();
Expr k = Compiler.Analyze(pconToUse, e.key());
Expr v = Compiler.Analyze(pconToUse, e.val());
keyvals = (IPersistentVector)keyvals.cons(k);
keyvals = (IPersistentVector)keyvals.cons(v);
if (!(k is LiteralExpr && v is LiteralExpr))
constant = false;
}
Expr ret = new MapExpr(keyvals);
if (form is IObj && ((IObj)form).meta() != null)
return Compiler.OptionallyGenerateMetaInit(pcon, form, ret);
else if (constant)
{
// This 'optimzation' works, mostly, unless you have nested map values.
// The nested map values do not participate in the constants map, so you end up with the code to create the keys.
// Result: huge duplication of keyword creation. 3X increase in init time to the REPL.
//IPersistentMap m = PersistentHashMap.EMPTY;
//for (int i = 0; i < keyvals.length(); i += 2)
// m = m.assoc(((LiteralExpr)keyvals.nth(i)).Val, ((LiteralExpr)keyvals.nth(i + 1)).Val);
//return new ConstantExpr(m);
return ret;
}
else
return ret;
}
开发者ID:davidadsit,项目名称:clojure-clr,代码行数:35,代码来源:MapExpr.cs
示例11: InvokeExpr
public InvokeExpr(string source, IPersistentMap spanMap, Symbol tag, Expr fexpr, IPersistentVector args)
{
_source = source;
_spanMap = spanMap;
_fexpr = fexpr;
_args = args;
VarExpr varFexpr = fexpr as VarExpr;
if (varFexpr != null)
{
Var fvar = varFexpr.Var;
Var pvar = (Var)RT.get(fvar.meta(), Compiler.ProtocolKeyword);
if (pvar != null && Compiler.ProtocolCallsitesVar.isBound)
{
_isProtocol = true;
_siteIndex = Compiler.RegisterProtocolCallsite(fvar);
Object pon = RT.get(pvar.get(), _onKey);
_protocolOn = HostExpr.MaybeType(pon, false);
if (_protocolOn != null)
{
IPersistentMap mmap = (IPersistentMap)RT.get(pvar.get(), _methodMapKey);
Keyword mmapVal = (Keyword)mmap.valAt(Keyword.intern(fvar.sym));
if (mmapVal == null)
{
throw new ArgumentException(String.Format("No method of interface: {0} found for function: {1} of protocol: {2} (The protocol method may have been defined before and removed.)",
_protocolOn.FullName, fvar.Symbol, pvar.Symbol));
}
String mname = Compiler.munge(mmapVal.Symbol.ToString());
IList<MethodBase> methods = Reflector.GetMethods(_protocolOn, mname, null, args.count() - 1, false);
if (methods.Count != 1)
throw new ArgumentException(String.Format("No single method: {0} of interface: {1} found for function: {2} of protocol: {3}",
mname, _protocolOn.FullName, fvar.Symbol, pvar.Symbol));
_onMethod = (MethodInfo) methods[0];
}
}
}
if (tag != null)
_tag = tag;
else if (varFexpr != null)
{
object arglists = RT.get(RT.meta(varFexpr.Var), Compiler.ArglistsKeyword);
object sigTag = null;
for (ISeq s = RT.seq(arglists); s != null; s = s.next())
{
APersistentVector sig = (APersistentVector)s.first();
int restOffset = sig.IndexOf(Compiler.AmpersandSym);
if (args.count() == sig.count() || (restOffset > -1 && args.count() >= restOffset))
{
sigTag = Compiler.TagOf(sig);
break;
}
}
_tag = sigTag ?? varFexpr.Tag;
}
else
_tag = null;
}
开发者ID:EricThorsen,项目名称:clojure-clr,代码行数:60,代码来源:InvokeExpr.cs
示例12: RecurExpr
public RecurExpr(string source, IPersistentMap spanMap, IPersistentVector loopLocals, IPersistentVector args)
{
_loopLocals = loopLocals;
_args = args;
_source = source;
_spanMap = spanMap;
}
开发者ID:stuman08,项目名称:clojure-clr,代码行数:7,代码来源:RecurExpr.cs
示例13: PersistentList
/// <summary>
/// Initialize a list with given metadata, first element and rest of list.
/// </summary>
/// <param name="meta">The metadata to attach.</param>
/// <param name="first">The first element in the list.</param>
/// <param name="rest">The rest of the list.</param>
/// <param name="count">The number of elements in the list.</param>
PersistentList(IPersistentMap meta, Object first, IPersistentList rest, int count)
: base(meta)
{
this._first = first;
this._rest = rest;
this._count = count;
}
开发者ID:101v,项目名称:clojure-clr,代码行数:14,代码来源:PersistentList.cs
示例14: Symbol
/// <summary>
/// Construct a symbol from interned namespace name and symbol name, with given metadata.
/// </summary>
/// <param name="meta">The metadata to attach.</param>
/// <param name="ns_interned">The (interned) namespace name.</param>
/// <param name="name_interned">The (interned) symbol name.</param>
private Symbol(IPersistentMap meta, string ns_interned, string name_interned)
: base(meta)
{
this._name = name_interned;
this._ns = ns_interned;
this._hash = ComputeHashCode();
}
开发者ID:kmartin,项目名称:clojure-contrib,代码行数:13,代码来源:Symbol.cs
示例15: ExtractAttributes
public static IPersistentMap ExtractAttributes(IPersistentMap meta)
{
if (meta != null && EXTRACT_ATTRIBUTES.isBound)
return (IPersistentMap)EXTRACT_ATTRIBUTES.invoke(meta);
return PersistentArrayMap.EMPTY;
}
开发者ID:davidadsit,项目名称:clojure-clr,代码行数:7,代码来源:GenInterface.cs
示例16: InstanceOfExpr
#pragma warning restore 414
#endregion
#region C-tors
public InstanceOfExpr(string source, IPersistentMap spanMap, Type t, Expr expr)
{
_source = source;
_spanMap = spanMap;
_t = t;
_expr = expr;
}
开发者ID:chrisortman,项目名称:clojure-clr,代码行数:13,代码来源:InstanceOfExpr.cs
示例17: CaseExpr
public CaseExpr( IPersistentMap sourceSpan, LocalBindingExpr expr, int shift, int mask, int low, int high, Expr defaultExpr,
SortedDictionary<int, Expr> tests, Dictionary<int, Expr> thens, Keyword switchType, Keyword testType, IPersistentSet skipCheck)
{
_sourceSpan = sourceSpan;
_expr = expr;
_shift = shift;
_mask = mask;
//_low = low;
//_high = high;
_defaultExpr = defaultExpr;
_tests = tests;
_thens = thens;
if (switchType != _compactKey && switchType != _sparseKey)
throw new ArgumentException("Unexpected switch type: " + switchType);
//_switchType = switchType;
if (testType != _intKey && testType != _hashEquivKey && testType != _hashIdentityKey)
throw new ArgumentException("Unexpected test type: " + testType);
_testType = testType;
_skipCheck = skipCheck;
ICollection<Expr> returns = new List<Expr>(thens.Values);
returns.Add(defaultExpr);
_returnType = Compiler.MaybeClrType(returns);
if (RT.count(skipCheck) > 0 && RT.booleanCast(RT.WarnOnReflectionVar.deref()))
{
RT.errPrintWriter().WriteLine("Performance warning, {0}:{1} - hash collision of some case test constants; if selected, those entries will be tested sequentially.",
Compiler.SourcePathVar.deref(),RT.get(sourceSpan,RT.StartLineKey));
}
}
开发者ID:richhickey,项目名称:clojure-clr,代码行数:28,代码来源:CaseExpr.cs
示例18: StreamSeq
/// <summary>
/// Construct a <see cref="StreamSeq">StreamSeq</see> from metadata and first/rest.
/// </summary>
/// <param name="meta">The metadata to attach</param>
/// <param name="first">The first item.</param>
/// <param name="rest">The rest of the sequence.</param>
StreamSeq(IPersistentMap meta, Object first, ISeq rest)
: base(meta)
{
_first = first;
_rest = rest;
_stream = null;
}
开发者ID:arohner,项目名称:clojure-contrib,代码行数:13,代码来源:StreamSeq.cs
示例19: PersistentStructMap
/// <summary>
/// Initialize a struct from given data.
/// </summary>
/// <param name="meta">The metadata to attach.</param>
/// <param name="def">The structure definition.</param>
/// <param name="vals">Values for the fixed keys.</param>
/// <param name="ext">Additional keys/values.</param>
protected PersistentStructMap(IPersistentMap meta, Def def, Object[] vals, IPersistentMap ext)
: base(meta)
{
_ext = ext;
_def = def;
_vals = vals;
}
开发者ID:arohner,项目名称:clojure-contrib,代码行数:14,代码来源:PersistentStructMap.cs
示例20: FnSeq
/// <summary>
/// Initialize from given metatadata, plus first, restFn, rest.
/// </summary>
/// <param name="meta">The metadata to attach</param>
/// <param name="first">The first of the sequence.</param>
/// <param name="restFn">The function to generate the next value.</param>
/// <param name="rest">The rest of the sequence..</param>
FnSeq(IPersistentMap meta, object first, IFn restFn, ISeq rest)
: base(meta)
{
_first = first;
_restFn = restFn;
_rest = rest;
}
开发者ID:arohner,项目名称:clojure-contrib,代码行数:14,代码来源:FnSeq.cs
注:本文中的IPersistentMap类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论